Interview Question 1, interview question _ PHP Tutorial

Source: Internet
Author: User
Interview Question 1: interview question. Interview Question 1: I recently saw an interview question on the internet. I did it as I started my blog. Because I recently studied PHP, I used P to interview question 1.

I recently saw an interview question on the Internet and made it as I started my blog.

I recently learned PHP, so I used PHP to solve it. However, the world language is one, and other languages can also be referred. The question is simple as follows:

There are 100 lamps in the hall, each of which is numbered from 1 to 100. Each lamp is controlled by a switch. (Click the switch, the light is on, and then the light is off. The switch number is the same as that of the controlled lamp .) At the beginning, the light is completely off. Click the switch according to the following rules.
For the first time, light up all the lights.
For the second time, click the switch in multiples of all 2.
For the third time, click the switch of all multiples of 3.
And so on. Next, click the switch that multiples of all N.
After 100th Press times, there are still several lights on in the hall.

The method is as follows:

1
 

There is a better method and will be updated later.

I recently saw an interview question on the Internet and made it as my first blog. Because I recently studied PHP, I used P...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.