posted by Nicki .
Suppose there are 500 pennies in a row... (math problem)?
The pennies are all "heads up"
Now suppose that 500 people line up and ...
Person #1 turns over all the pennies
Person #2 turns over every 2nd penny, starting with penny number 2
Person #3 turns over every 3rd penny, starting with penny number 3
Person #4 turns over every 4th penny, starting with penny number 4
After everyone has gone through the line, which pennies will show "tails"?
This has to do with the number of factors of numbers.
For example, 6 has 4 factors: 1,2,3,6
Note how neatly the outermost factors (1,6) multiply to give 6, and the inner set (2,3) also.
You will note that almost all numbers, prime or composite, have an even number of factors, hence almost all coins will be turned over an even number of times, which in turn makes them remain "head".
The only exceptions are perfect squares, such as 1,4,9,16,...
For example, 16 has factors:
1,2,4,8,16 (note: 1*16=16,2*8=16,4*4=16).
where 4 is actually twice, but with an odd number of factors.
Therefore, the only coins that remain "tails" up are the perfect squares.
See also a previous discussion on a similar problem: