There is a line of lockers numbered 1 to 1024, initially all closed.
A man walks down the line, opens 1, then alternately skips and opens each closed locker (so he opens 1, 3, 5, ... , 1023). At the end of the line he walks back, opens the first closed locker, then alternately skips and opens each closed locker (so he opens 1024, skips 1022 and so on).
He continues to walk up and down the line until all the lockers are open.
Which locker is opened last?