The new school has exactly 1000 students and 1000 lockers.On the first day all the students meet outside and agree on the following plan: the first student will enter the school and open all the lockers.The second student will then enter the school and close every locker with an even number (2,4,6,8..).The third student will the reverse every third locker (3,6,9,12...).That is if the locker is closed,he/she will open it ,and if is open ,he/she will close it.The 4th student will then reverse every fourth locker and so on until all 1000 students in turn have entered the building and reversed the proper lockers.

A very old problem

Here is a great explanation

http://www.daniweb.com/forums/thread217790.html#

To find out which lockers are open at the end, we can simulate the process and keep track of the result.

1. First, create a list or an array of 1000 lockers, initialized as closed. We can represent an open locker as "1" and a closed locker as "0". Let's call this list "lockers".

2. Iterate through each student from 1 to 1000. For each student, perform the corresponding operation on the lockers.

a. For the first student, simply open all the lockers by setting all elements in the "lockers" list to 1.

b. For the second student, iterate through the lockers using a step of 2 (even indices) and toggle their state (i.e., if open, close, and vice versa).

c. For the third student, iterate through the lockers using a step of 3 and toggle their state.

d. Continue this process for each subsequent student, using a step equal to their student number.

3. After all 1000 students have performed their operations on the lockers, count the number of open lockers.

4. Print or return the count of open lockers.

Here's a Python code implementation of this process:

```python
# Step 1: Initialize the list of lockers
lockers = [0] * 1000

# Step 2: Simulate the students' actions
for student in range(1, 1001):
for locker in range(student - 1, 1000, student):
lockers[locker] ^= 1 # Toggle the locker's state

# Step 3: Count the number of open lockers
open_lockers = sum(lockers)

# Step 4: Print the result
print("Number of open lockers:", open_lockers)
```

Running this code will output the number of open lockers at the end of the process.