Aye - and why squares?

In the process of turning cards, we can think of the "deck" as the totality of integers, and ask what happens to any integer. Suppose the integer is prime - then the only factors are 1 and the number, so it gets turned exactly twice, and at the end, is face up. If not prime, then the number will usually have various representations M = IJ with I and J less than M and I not equal J - since there are two distinct factors, M will again be turned twice for each such representation, and at the end, will have been turned an even number of times and be face up.

There is one exception - if M is a square, then it has a representation M = JJ, and gets turned only once for this representation, so the total number of turns it undergoes is odd - and it ends up face down.