All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars
 perplexus dot info

 Opening doors (Posted on 2002-05-01)
Imagine a row of 100 closed doors. Now, make 100 passes along the row, and at each pass "toggle" the doors whose number is divisible by the number of the pass. (By "toggle", we mean to open a closed door, or close an opened one.)

For example, on the first pass, we will toggle all the doors, on the second, we will toggle only the even-numbered doors, on the third - only doors whose number is divisible by three, and so on.

At the end of the 100 passes, how many doors will be left open?

(from techInterview.org)

 See The Solution Submitted by levik Rating: 3.5000 (6 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
 re: The solution... | Comment 9 of 12 |
(In reply to The solution... by Paul Pereira)

What about the 4th door? It is opened the first pass, closed the second pass and opened again the fourth pass, and that's it.
 Posted by Gamer on 2003-07-03 14:33:20

 Search: Search body:
Forums (1)