The stuff he said at the end is good stuff!
He started by looking for a pattern that shows which lights are on or off at the end:
(Here an arrow refers to a switch being flipped.)
All the lights start off being off. (That's a weird sentence!)
off → on
off → on →off
off → on → off → on
off → on → off → on → off
The pattern is that if there are an odd number of flips (arrows), then the light is on!
Now, what does this have to do with the 6?
The neat idea here is that the number of flips is really the number of factors of a number. This makes sense, because each the Xth person is going through, finding multiples of X, and flipping their switches.
The number 6 equals the number of factors of 20. The stuff at the end is a quick explanation of how to find the number of factors of a number. You write
20 = 2² × 5¹
To get factors, we "choose" how many 2's we want in our number, and "choose" how many 5's we want. There are three choices for the number of 2's: zero, one or two 2's. There are two choices for the number of 5's: zero or one 5. So there are 3 × 2 = 6 ways to make a factor of 20.
But we saw that if the number of factors is even, then the light will be off, since the number of off-flips and on-flips will cancel each other out.
So since 20 has an even number of factors (6 factors), its switch will be off!
This is such a cool idea, because it basically liberates you from having to calculate things by hand. Would you rather draw a huge grid and painstakingly figure out all the factors of each number, then coloring in the squares. or would you rather use neat tricks to just find the numbers that have an odd number of factors (basically numbers that have only odd powers of primes in their prime factorizations)? I know I wouldn't!
Please ask if you have any more questions; we love answering them!
The Daily Challenge Team