An Amazing Mathematical
Card Trick
by Martin Gardner in
GAMES (FEBRUARY 2010)


One of the finest of all mathematical magic tricks, not well known even to card magicians, was invented by Howard Adams.   It was first published in his now rare 1984 booklet titled "OICUFESP" (as in "Oh, I see you have ESP").

I urge you to get a deck of cards and astonish yourself by following these simple instructions.   First, remove from the deck a set of five pairs of "mated" cards.   (A mate to a card is a card with the same value and color, i.e., the mate of the queen of hearts is the queen of diamonds.)   Call the five cards ABCDE and their mates abcde.   Arrange them in the order ABCDEabcde and place the packet of 10 cards facedown on a table.   You can then cut this packet of cards as many times as you want.   (Cutting a packet means lifting some cards off the top, thereby separating the packet into two parts, and then transposing the two parts as you put them back together, always keeping the facedown orientation of all the cards.)   Then split the packet in half (i.e., cut it into two sets of five cards each) and place the halves facedown on a table, side by side.   Then turn the five-card pile on the right faceup.

You are now going to spell the words in the phrase LAST TWO CARDS MATCH in the following way.   Pick up either pile (you can let someone else choose which one) and spell the letter L by moving the top card of the pile to the bottom, and then putting the pile back on the table without turning it over.   Likewise spell the letter A of LAST by once again picking a pile at random, moving its top card to the bottom, and putting the pile back on the table, keeping the faceup or facedown orientation of the cards.   The spellings of S and T are done in the same way.   After the first word is completed, we still have two piles, one faceup and the other facedown.   Now remove the top card from each pile and set them aside, side by side, at some vacant spot on the table.   One will be facedown and the other will be faceup.

Repeat the process with the remaining piles of four by spelling the word TWO, picking a pile at random for each letter.   After the word is spelled out, remove the top card from each pile and set them aside as before, side by side, below the previously removed pair of cards.   Proceed by spelling CARDS and MATCH with the remaining piles, again removing the top cards after completing each word and setting them aside.

You will now have two columns of cards (made up of the four sets of removed cards), plus the two cards that are the last two cards left in your starting piles.   Focus on those last two cards, and turn over the one that's facedown.

Surprise-it matches the other card!

But that's not all.   The trick has a second, even greater climax.   Turn over the remaining four facedown cards.   Each one will match the faceup card it is paired with!

Maybe you can figure out why the trick works.   It is based on modular arithmetic.   Once you have figured out why, you may be ready for the challenge of devising a similar magic formula that will work for larger sets of cards, or even for the entire deck!


An explanation of the trick from Mr. P

Using the trick above, look at the two columns in the table below:

Cards in the Pile         Length of Word
5         4 (LAST)or 9 or 14
4         3 (TWO) or 7 or 11
3         2 or 5 (CARDS) or 8
2         1 or 3 or 5 (MATCH)


The length of the word just means how many times you take the top card of one pile and move it to the bottom of that pile.   In the example above, the four words, LAST TWO CARDS MATCH were used to count how many times you removed a card from the top of the pile and placed it on the bottom.   You could have used the words LAST TWO TO MATCH and the trick still works because 5 MOD 3 = 2 MOD 3 = 2.   The 5 represents the number of letters in CARDS and the 2 represents the number of letters in TO, and when you MOD them with 3, you get 2.

When there are five cards in each pile, then the length of the word is given by: length MOD 5 = 4.
So, length could be 4 (the word LAST) or 9 or 14 or 19 or 24.
When there are 4 cards in each pile, then the length of the word is given by: length MOD 4 = 3.
So, length could be 3 (the word TWO) or 7 or 11 or 15 or 19.
When there are 3 cards in each pile, then the length of the word is given by: length MOD 3 = 2.
So, length could be 2 or 5 (the word CARDS) or 8 or 11 or 14.
When there are 2 cards in each pile, then the length of the word is given by: length MOD 2 = 1.
So, length could be 1 or 3 or 5 (the word MATCH) or 7 or 9.

So, in general, if there are N cards in each pile, then you would remove the top card and place it on the bottom of the pile N - 1 times.   The number of times you must move a card is given by: X MOD N = N - 1, where N is the number of cards in each pile and X is the number of times you must move a card from the top to the bottom of the pile.   There is an infinite number of solutions for X.

Using this information, let us extend the trick to eight cards in each pile (a total of 16 cards or eight pairs of "mated" cards.   The table below shows the number of times you must move the top card:

Cards in the Pile         Number of Times to Move Top Card
8         7 or 15 or 23
7         6 or 13 or 20
6         5 or 11 or 17
5         4 or 9 or 14
4         3 or 7 or 11
3         2 or 5 or 8
2         1 or 3 or 5


Of course, the easiest way to do this trick is just to remember this:
If there are N cards in each pile, just remove the top card and put it on the bottom N - 1 times.   But the trick is better if you use the MOD function and choose a different number when you repeat the process.   In the first example, you could have done 4, 3, 2, and 1 instead of 4, 3, 5, and 5 (LAST, TWO, CARDS, MATCH) but using words or varying the number of times adds to the illusion.

If you REALLY want to impress your students, you could do the trick with the FULL DECK.   I must thank my wife for indulging me by doing the entire deck!!   She liked the trick but she said it was too much counting!   Here is how you set up the trick for the full deck:

First, arrange the 52 cards by suits from A, 2, 3, ... to J, Q, K.   Then alternate red and black suits, combining the cards into one pile.   Then proceed as before.
    Have someone cut the deck as many times as they want to.
    Then take the top 26 cards and place them face up, leaving the other 26 cards face down.
    Then have the person remove the top card from either pile and put it on the bottom.
    Have the person do it 25 times, then remove the top card from each pile and set them aside, side by side, at some vacant spot on the table.

    Now, repeat this process twenty-four more times.   When there are 25 cards in each pile, remove the top card (from either pile) 24 times.   When there are 24 cards, do it 23 times; when there are 22 cards, do it 21 times; all the way until there are just 2 cards in each pile, just do it once.   Here is a partial table, showing how many times to remove the top card when you have a certain number of cards in each pile:

Cards in the Pile         Number of Times to Move Top Card
26         25
25         24
24         23
23         22
22         21
21         20
......         ......
8         7 or 15 or 23
7         6 or 13 or 20
6         5 or 11 or 17
5         4 or 9 or 14
4         3 or 7 or 11
3         2 or 5 or 8
2         1 or 3 or 5


If you can devise a seven word English phrase to help with the 16 card trick, please send it to me.



Many thanks to Piet Tutelaers who sent in the following ideas:
Arrange bundle until pile doesnot house buddies.
Dispose bundle until pile doesnot house friends.

Both of these sentences work because the words have lengths:
7, 6, 5, 4, 7, 5, 7.
The last three lengths are equivalent to 3, 2, 1:
7 mod 4 = 3, 5 mod 3 = 2, 7 mod 2 = 1.

You could substitute the word CARDS for BUDDIES or FRIENDS and it works because 5 mod 2 = 1.
So, the sentence could read:
Arrange bundle until pile doesnot house cards.


Send any comments or questions to: David Pleacher