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...