Imagine 30 doors in a row, numbered 1 to 30. At the start every door
is
closed.
Then you follow this routine:
- On the 1st pass, you toggle (open if closed, close if open) every door (every 1st
door).
- On the 2nd pass, you toggle every 2nd door (doors 2, 4, 6, ...).
- On the 3rd pass, you toggle every 3rd door (doors 3, 6, 9, ...).
- You keep going like this: on pass k toggle every k-th door, up to pass 30.
Question: After the 30th pass, which doors are left open?