1000 lockers 1000 students, the first student goes along and opens every other locker. The second student goes along and shuts every other locker beginning with the number 2. The third student changes the state of every 3rd locker begining with the number 3 (if the locker is open the student shuts it and if closed the student opens it.the 4th student changes the state of every 4th locker begining with number 4. all students follow the pattern with the thousand lockers. at the end which lockers will be open and which will be closed? and why?

The solution is explained here:

http://stanwagon.com/public/TorrenceWagon.pdf

Only locker numbers with an even number of factors remain open. Those turn out to be perfect squares: 1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, .., 900 (31)^2=961
Count them up. I think you will get 31 open lockers

To determine which lockers will be open and which will be closed at the end, we need to analyze the pattern created by the students' actions.

Let's consider the process step by step:

The first student starts by opening every other locker, so all even-numbered lockers (2, 4, 6, ...) are open, and all odd-numbered lockers (1, 3, 5, ...) remain closed.

The second student then goes through and shuts every other locker starting with the number 2. This means that the second student will change the state of all even-numbered lockers. So, all the even-numbered lockers will now be closed, while the odd-numbered lockers will remain as they were.

The third student changes the state of every 3rd locker starting with the number 3. This will involve the student switching the state of every third locker (3, 6, 9, ...). If the locker was closed, it will be opened, and vice versa.

The fourth student changes the state of every 4th locker starting with the number 4. Similar to the third student's action, the fourth student will toggle the state of every fourth locker (4, 8, 12, ...).

This pattern continues with each student taking turns, changing the state of lockers that are multiples of their position.

To determine the final state of each locker, we can analyze the number of times a particular locker is toggled.

For example, if a locker is toggled an even number of times, it will end up in the same state as when it started (either open or closed). If a locker is toggled an odd number of times, it will end up in the opposite state.

Let's consider a locker number, say locker #17. It will be toggled by the following students:

- The first student (opens every other locker)
- The 17th student (changes every 17th locker)

Since 17 is prime, it means it has only two factors: 1 and 17. So, locker #17 will be toggled twice, ending up in its original state. Similarly, only lockers with prime numbers will end up in their initial state. In other words, all lockers that have an even number of factors (except for perfect squares) will be closed, while lockers with an odd number of factors will be open.

For example:
- Locker #16 has factors 1, 2, 4, 8, and 16, so it will be closed.
- Locker #9 has factors 1, 3, and 9, so it will be open.

Hence, at the end, 31 lockers will be left open (those with odd numbers as their positions, i.e., 1, 4, 9, 16, 25, etc.), and the remaining 969 lockers will be closed.

Note: This problem is based on the concept of factors and perfect squares. Factors are the numbers that divide exactly into another number, and perfect squares are numbers whose square roots are integers.