Mathematical card tricks
A mathematical card trick has a theorem where the sleight of hand would be. You deal by a rule, and the rule forces the ending. Nothing is palmed, nothing is switched, and nothing depends on your hands being quick.
Ten of these are collected in a free mathematical card tricks PDF — fifteen pages, arranged by the same principles, free to print and hand out, with no email form in front of it.
This list is sorted by the mathematics underneath, because there are only about four ideas here and once you have one of them you have every trick built on it. Parity. Sorting in base three. Arithmetic that wraps at thirteen. And a quantity that cancels itself out.
Every trick below runs in your browser before you touch a deck, from either side of the table. And where the claim is arithmetic, the demo tests it against every case — all twenty-one starting positions, all twenty-seven numbers a spectator can name, every number from five to eighteen.
Parity
Odd and even, and the fact that dealing cannot change it
Split any even number of things into two heaps and the heaps are both odd or both even together. Add one more thing to one heap and you have broken the tie permanently. No amount of moving pairs around puts it back. That is the whole idea, and it is the first piece of mathematics most people meet without noticing.
The Piano Trick
Their hands rest on the table like a pianist's. You slot pairs of cards between their fingers, then one last single card. The pairs are split into two piles, and without seeing anything you name which pile the odd card is in.
The math: the pairs keep both piles even together. The single card breaks it, and it can never be broken back. You are not tracking a card — you are tracking whether a number is odd.
Play it →Base three, or ternary
Three piles, three deals, and 3 × 3 × 3 = 27
Deal cards across three piles and ask which pile something is in, and you have learned exactly one digit of a base-three number. Do it three times and you have learned three digits, which is enough to name one thing out of twenty-seven. These two tricks are the same idea run at two different sizes, and they are the reason mathematicians write about card tricks at all. Written in base three, a number has only the digits 0, 1, and 2, which is exactly as much as a pile can tell you. That is why these are called ternary routines.
The 21 Card Trick
Somebody picks one of twenty-one cards. You deal three piles, three times, asking only which pile it is in — never which card, and you find it.
The math: each deal cuts the possibilities to a third. Twenty-one, then seven, then three, then one. Gathering their pile in the middle each time is what makes the narrowing land in the same place, so their card finishes 11th every single time. Checked: all 21 starting positions.
Play it →The 27 Card Trick
Somebody thinks of a card. Then, before you touch anything, they name any number from 1 to 27. You deal three times and their card is sitting at exactly the number they asked for.
The math: 27 is three cubed. Take the number they named, subtract one, and write it in base three. You get three digits, and each digit tells you whether their pile goes on top, in the middle, or underneath that round. Nothing else about it is a decision. Checked: all 27 numbers a spectator can name.
Play it →Arithmetic that wraps, or modular arithmetic
Adding three, over and over, and counting to thirteen
Thirteen ranks and four suits. Step through the deck adding three to the rank each time and wrapping around at thirteen, and cycle the suits in a fixed order, and you have a deck where every card tells you the next one. It will pass a riffle and a cut and still be in order, because a cut does not change what follows what.
The Si Stebbins Stack
A deck in a secret order that looks, when you riffle it, exactly like a shuffled one. Learn two small sums and you know the card underneath any card named, the card at any position, and where a named card is sitting.
The math: rank plus three, modulo 13. Suit advances by one, modulo 4. Both sums are small enough to do while talking, which is the only reason this is performable rather than merely clever.
Play it →A quantity that cancels
The strongest idea here, and the least known
The best mathematical tricks do not compute the answer. They arrange for the thing you do not know to disappear from the expression. A spectator makes a free choice, that choice enters the arithmetic twice with opposite signs, and it is gone. You never learn it because you never needed it.
The 13 Card Trick is the clearest example on this site, because two quantities cancel rather than one, and you can watch both leave.
The 13 Card Trick
Deal the deck into piles, counting up to 13 each time. Three piles are kept, you gather the rest, and you name the value of a card nobody has seen.
The math: a pile started with v holds 14 − v cards. Deal any number of piles and gather all but three, and both the pile count and the sum of every card you dealt cancel out. Your hand is left holding 10 plus the three bottom cards on the table. Checked: 200,000 random deals.
Play it →Easy Location
They think of a number, take that many cards off the top, and remember a card you never see. Three piles counted down from ten find it.
The math: the number they chose subtracts from one part of the count and adds back to another, so it cancels completely. Their card sits 34th whatever they picked, and it stays 34th whether they hand their packet back or keep it in their pocket, because their cards sit below it and nothing below a card can move it. Checked: every number from 5 to 18.
Play the trick →Aldo Colombini's, from his book Impromptu Card Magic. Playing it is open to anybody. The method is his, so it opens to people who own the book.
The size of the haystack
Why any of this is surprising in the first place
A deck of 52 can be in 8 × 1067 different orders. Every trick above is a way of not searching that, and the number itself is worth knowing, because the usual version of it is overstated.
52 factorial
The exact 68-digit number, a calculator for any deck size, and a real deck you can riffle while it counts what is left of the order.
The correction: there are not more ways to shuffle a deck than atoms in the universe. The universe wins by a factor of 1.24 trillion. The true version of the claim uses Earth.
See the number →How many times should you shuffle a deck?
Seven is the famous answer, and it assumes you cut the deck roughly in half every time. Cut carelessly and it is about fourteen.
The math: a new deck is one rising sequence, each riffle roughly doubles them, and a random deck averages 26.5. Seven doublings gets you there. Checked: 400 decks a row, and seven leaves a carelessly cut deck at 66%.
Break up a deck →Why are there 52 cards in a deck?
52 weeks, four seasons, thirteen lunar months. The arithmetic really works — 91 to a suit, 364 to a deck, 365 with a joker.
The correction: the dates run the wrong way. A Mamluk pack in the Topkapı Palace already has 52 cards in four suits of thirteen, a century before French suits existed, and the suits were cups, coins, swords and polo-sticks. Checked: the sums are computed here, and the same French suits ship as a 32-card pack in France.
See what came first →The binary card trick
Think of a number, hand back every card it appears on, and the corner numbers add up to it. Five cards name anything from 1 to 31.
The math: each card is one binary digit, so handing one back says that digit is a 1. Adding the corners reads the number out of its own spelling. Checked: for every number in range, the cards holding it add to exactly it.
Have your number named →The Gilbreath principle
Alternate the colors, deal any number off the top, and let the spectator riffle as badly as they like. Every pair still comes out one red and one black.
The math: dealing reverses, so the finished deck read from the bottom is the original deck read forwards from card 1 interleaved with the same deck read backwards from card 52 — and those two start on opposite colors. Checked: 200,000 deals, zero failures, and the cut measured separately.
Riffle it yourself →The de Bruijn sequence card trick
Thirty-two cards, cut wherever the spectator likes. Five people take the top five and say only whether their card is red or black. That names all five.
The math: five colors give 25 = 32 patterns and the packet has 32 places to cut, so there are exactly enough patterns for every cut to have its own. The sequence is cyclic, which is why a cut leaves it alone. Checked: 32 windows, 32 distinct patterns, and every one decodes back to its own cut.
Have five cards named →The faro shuffle
Cut the deck into two exact halves and interlace them one card at a time. Eight of those and the deck is in precisely the order it started in.
The math: an out-faro sends the card at position i to 2i modulo 51, so after k shuffles it is at 2ki, and the deck is back when 2k = 1. That is eight, because 256 is 5 × 51 + 1. A fact about 51, not about cards. Checked: both counts derived and then measured.
Shuffle it →Close relatives
Counting rather than mathematics, and worth knowing why
Two more on this site run on position rather than on a theorem. In the Four Robbers three ordinary cards ride on top of four Jacks, so the cards you push into the deck are the strangers and the Jacks never move. In Spectator Cuts to the Aces the dealing buries the aces exactly three deep, so moving three cards digs them out again.
Both are arithmetic in the sense that a recipe is chemistry. They are counting, done carefully. Calling them mathematical card tricks stretches the phrase, and knowing where it stretches is part of understanding the rest.
Questions people ask
What is a mathematical card trick?
A card trick whose method is a piece of mathematics rather than a sleight. You deal according to a rule, and the rule forces the ending.
The usual principles are the four above: parity, sorting in base three, arithmetic modulo 13, and quantities that cancel out of an expression. Nothing is palmed and nothing is switched, so nothing can go wrong with your hands.
What are some card tricks that use math?
The Piano Trick runs on odd and even. The 21 Card Trick and the 27 Card Trick both sort in base three. The Si Stebbins stack is arithmetic modulo 13 and modulo 4. Easy Location works because the number the spectator chooses cancels out of the arithmetic entirely.
Do you have to be good at math to do them?
No. The mathematics is why the trick works, not what you do.
Performing the 21 Card Trick asks you to deal three piles and remember to gather the named pile in the middle. Only the Si Stebbins stack asks you to add while somebody is watching, and that sum is adding three.
Which mathematical card trick is best for a classroom?
The 27 Card Trick, because the answer is base three and the trick cannot be explained without it. A spectator names any number from 1 to 27, and each digit of that number written in base three tells the performer where to put one pile.
The 21 Card Trick is the easier first demonstration. The Piano Trick is the fastest way to show that parity survives being moved about, and it takes three minutes.
How do you do a mathematical card trick?
Step by step, and the steps are the whole method. Take the 21 Card Trick, which is the one most people mean: deal 21 cards into 3 piles of seven, ask which pile holds their card, gather that pile between the other two, and repeat twice more. Their card finishes eleventh, every time.
There is nothing to palm and nothing to switch. If you can deal into three piles and remember which one goes in the middle, you can already do it, and you can run the whole thing on screen here before you pick up a deck.
Why does the 27 card trick work?
Because 27 is 3 × 3 × 3, so three questions about three piles are exactly enough to name one card out of 27. Each answer gives you one ternary digit.
The full working, with the deal tested against all 27 numbers a spectator can name, is on the 27 Card Trick page.
How does the guessing card trick work?
It usually does not guess. In every trick on this page the ending was fixed before the spectator chose anything, and the choice they make is either narrowing the answer for you, as in the pile tricks, or cancelling itself out of the arithmetic, as in Easy Location.
That is the honest difference between a mathematical trick and a mind-reading claim. Nothing is being read, because nothing needs to be.
Which mathematical card trick is best for beginners?
The Piano Trick, which takes about three minutes and has no counting in front of an audience at all. After that the 21 Card Trick, which is the standard first one and asks only that you deal three piles the same way three times.
Leave the Si Stebbins stack until last. It is the only one here that asks you to do arithmetic while somebody is watching you.
Which mathematical card trick is best for kids?
The Piano Trick and the 21 Card Trick. Both are short, neither has a move, and a child can perform either after two run-throughs.
The 27 Card Trick is the one worth showing a class learning number bases, but it needs somebody who can already convert a number into base three, which is usually the teacher.
Is there a math card trick with 3 piles?
Three of them, and the three piles are doing the same job each time. The 21 Card Trick deals 3 piles of seven, the 27 Card Trick deals 3 piles of nine, and Easy Location counts three piles down from ten.
Asking which of three piles a card is in is a question with three answers, so it hands you one base-three digit. Three piles is not a presentation choice. It is the number that makes the arithmetic work.
Is there a math card trick that uses all 52 cards?
Two. The Si Stebbins stack orders the whole deck so that every card tells you the next one. Easy Location uses a full 52 and finishes on the 34th card every time, whatever number the spectator thought of.
More
All ten, mathematical or not, are on the self-working card tricks page — including the ones that run on a key card, a switch, or a story rather than on a sum.