Mathematics Awareness Month 2014: Mathematics, Magic, and Mystery

Navigate the Calendar

The 27 Card Trick

For the 27th day of the month, stand-up mathematician Matt Parker presents his version of the 27 card trick, followed by a variant of his own creation:

Matt is back to explain the 27 card trick in this Numberphile video:

Taking it Further

  1. Why does Matt only need to deal the cards twice for the 49 card trick?
  2. Can you design a similar trick that uses a different number of cards?
  3. At the very end of the second video above, Matt discusses the 10 billion card trick, in which you deal 10 billion cards into 10 piles, with a billion cards in each pile. After doing this just 10 times, you can put the subject’s chosen card into any of the 10 billion positions in the deck! Amazing as this seems, discuss the impracticality of this feat: Approximately how tall would a 10 billion card deck be? Estimate how much it would weigh. Approximately how long would it take to deal it into 10 piles?

The Underlying Mathematics

The 27 card trick is based on the ternary number system, sometimes called the base 3 system.

Suppose the volunteer chooses a card and also chooses the number 18. You want to make her chosen card move to the 18th position in the deck, which means you need 17 cards above it. You first need to express 17 in base 3, writing it as a three digit number. For the procedure used in this trick, it’s also handy to write the digits in backward order: 1s digit first, 3s digit second, and 9s digit last. In this backward base 3 notation 17 becomes 221, since

17 = 2×30 + 2×31 + 1×32.

With the understanding that 2 = bottom, 1 = middle, and 0 = top, the number 17 becomes “bottom-bottom-middle.”

Now deal the cards into three piles. The subject identifies the pile containing her card. That pile should be placed at the position indicated by the 1s digit, which is 2, or bottom. After picking up the three piles with the pile containing the chosen card on the bottom, deal the cards a second time into three piles. This time place the pile containing the chosen card in the position indicated by the 3s digit, which is also 2, or bottom. Finally, after placing the pile containing the subject’s card on the bottom, deal the cards into three piles for a third time. When picking up the piles, this time place the pile containing her card in the position indicated by the 9s digit, which is 1, or middle. Deal out 17 cards. The 18th will be her card.

Making a schematic picture of the deck, like Matt does in his second video, should convince you that this procedure does precisely what is claimed. But there is no substitute for actually doing it—take 27 cards and try it!

Of course this procedure will work regardless of which position the subject chooses, for her choice is always a number between 1 and 27. This means you need between 0 and 26 cards on top of it, and in base 3 we have 0 = 000 (top-top-top) and 26 = 222 (bottom-bottom-bottom). Every possible position that the subject can choose corresponds to a unique base 3 representation.

In general, if you deal a pack of nk cards into n piles, have the subject identify the pile that contains her card, and repeat this procedure k times, you can place her card at any desired position in the deck. The idea is the same: Subtract one from the desired position number, and convert the result to base n as a k digit number. The ones digit of this number tells you where to place the packet containing her card after the first deal (n – 1 = bottom, 0 = top), and the procedure continues for the remaining deals.

In Mathematics, Magic and Mystery (Dover, 1956), Martin Gardner discusses the long history and many variations of this effect. See Chapter 3, “From Gergonne to Gargantua.”