A new high school has just been opened, with an enrollment of 1000 students. The school has 1000 lockers, numbered 1 to 1000, to accommodate them. On the first day of school all 1000 lockers are closed. The first student enters the school and opens all of the lockers. The second student follows and closes every second locker, beginning with the second locker. The third student enters the school and reverses every third locker beginning with the third. This procedure continued until all 1000 students have passed by all of the lockers. When they finish, which lockers will be open?

I think all of the lockers will be open at the end

To solve this problem, we need to determine which lockers will be open at the end. Let's break down the steps, and I'll explain the reasoning behind them.

1. The first student enters the school and opens all of the lockers. So after the first student, all the lockers will be open.

2. The second student follows and closes every second locker, beginning with the second locker. This means the second student will close lockers 2, 4, 6, 8, and so on.

3. The third student enters the school and reverses every third locker beginning with the third. So the third student will change the state of lockers 3, 6, 9, 12, and so on. The third student will open all the lockers that were previously closed and vice versa.

4. Following the same pattern, each subsequent student will change the state of specific lockers based on their student number. For example, the fourth student will change the state of lockers 4, 8, 12, 16, and so on.

Now, let's determine which lockers will be open at the end. In general, a locker will be opened or closed based on the total number of times it is visited by the students. If a locker is visited an odd number of times, it will be open, and if it's visited an even number of times, it will be closed.

We need to find the lockers that are visited an odd number of times. To do this, we can examine the factors of each locker number.

For example, let's consider locker 12. Its factors are 1, 2, 3, 4, 6, and 12. The third student will reverse this locker because 3 is a factor of 12. Also, the fourth student will reverse it once again since 4 is a factor of 12. So the locker will be visited by two students, making it closed at the end.

In general, a locker will have an odd number of factors if it is a perfect square. Why is this the case? Let's take an example of locker 16. Its factors are 1, 2, 4, 8, and 16. Notice that the factors come in pairs, except for the square root (4) which is not paired with another number. So this locker will be visited by three students: the second student (to close it), the fourth student (to open it), and the sixteenth student (to close it again).

With this information in mind, we can conclude that only the lockers numbered by perfect squares will be open at the end. These lockers will be visited an odd number of times, ensuring that they remain open.

There are 31 perfect squares between 1 and 1000 (inclusive): 1^2, 2^2, 3^3, ..., 31^2.

Therefore, the open lockers at the end will be numbers 1, 4, 9, 16, ..., 961, 1000.