Pick a 3-digit number where the first and last digits differ by 2 or more...
Why is this always equal to 1089?
This is one of the better tricks of its kind,
because the effect of reversing the digits isn't obvious to most people at first...
If the 3-digit number reads abc, it's equal to
100a+10b+c and the second step gives the following result:
| (100a+10b+c) -
(100c+10b+a) | = 99 | a-c |
The quantity | a-c | is between 2 and 9,
so the above is a 3-digit multiple of 99, namely:
198, 297, 396, 495, 594, 693, 792 or 891.
The middle digit is always 9,
while the first and last digits of any such multiple add up to 9.
Thus, adding the thing and its
reverse gives 909 plus twice 90, which is 1089, as advertised.
Henri Monjauze (2008-02-07)
Multiples of nine
Pick a 2-digit number...
How can the magician predict what that symbol is?
The trick will become boring (or obvious) if the same table is used repeatedly.
Thus, a new table must be provided each time. Several online implementation
do this quite effectively, with nice graphics. Examples:
How fast can you discover the secret which makes this work?
[ Answer ]
Art Benjamin (2010-05-29)
Casting out nines
Figure out the missing digit in a large product of two integers.
The magician hands out a 3 or 4-digit integer chosen by a spectator in a previous
part of the show. Using a pocket calculator, another spectator multiplies that
number by some secret 3-digit number which he chooses freely and keeps for himself.
The result is a 6 or 7-digit number. The spectator withholds one of those digits
and reveals all the others in a random order. The magician then reveals the
The trick is based on arithmetic modulo 9, which is
what underlies the process of
casting out nines
from an integer, which is very familiar to schoolchildren (at least it used to be).
Casting out nines is a quick way to obtain the remainder when an integer
N is divided by 9
(the key observation is that 10 and all the powers of 10 leave a remainder of 1,
therefore, a number and the sum of its digits leave the same remainder).
See elsewhere on this site
for other divisibility rules.
The number handed out by the magician is a multiple of 9 (Art Benjamin
takes it from a random list of perfect squares coming from a earlier stage of
the show; each of those has one chance in 3 of being divisible by 9 and
the earlier stage went on until a "good" number came up).
The result is therefore a multiple of 9 and the sum of its
digits is a multiple of 9.
When all the digits but one are revealed, the last one is thus known
modulo 9. This does reveal it unless it's either
a zero or a nine. In that ambiguous case, the magician will guess
it to be a 9 and will almost always be right because people will rarely
skip a zero when they are told to skip any digit they like.
If you'd rather not take any chances at all, then instruct people to skip a
A quick way to obtain the missing digit mentally is to first work
out the remainder modulo 9
of the sum of the digits you are given (just add together the digits and
repeat, if needed, until you obtain a single-digit result).
Subtract the result from 9. Done, unless you get zero
(in which case you'd guess "9" instead, as previously discussed).
Many variants of this trick can be devised based on any obscure process
which produces a multiple of 9.
Here is one:
Ask a spectator to pick any 4-digit number and to consider the number
obtained by reading it backwards.
Let the spectator secretly subtract the lesser number
from the larger one, add 54 and multiply the result by a 3-digit number
freely chosen by the spectator...
Ask how many digits there are in the final result and ask the spectator
to keep one nonzero digit secret and to reveal the other
digits in scrambled order.
(Count ostensibly on your fingers how many digits you are given to make sure you're
only missing one.)
You may then call the remaining digit with perfect accuracy.
The Triple Threat. Mind Reading.
Guess with perfect accuracy which one of three cards was chosen.
The following effect can be repeated as many times as needed
to convince the spectators that you can read their minds with
perfect accuracy as they pick one of three choices.
Put three cards face-up on the table.
Ask a spectator to choose one mentally
and remember its position. Flip the three cards over.
Turn around and instruct the spectator to show the other spectators
which card he has chosen, then have him switch the two
other cards behind your back.
Now face the table again and instruct the spectators to switch
cards as many times as they wish in front of your eyes.
Reveal the card originally chosen by the spectator.
Before you flip the cards and turn around, remember which card is in the
middle. When you face the table again, focus of the card which
is now in the middle and keep track of its position as spectators move
Flip that card.
If this is the card you had memorized, simply announce that this
is the card the spectators have chosen (this is so because the spectator
clearly hasn't switched the middle card behind your back in this case).
Otherwise, the chosen card can be neither the one you had memorized nor
the one you're now seeing. It's the third card.
Mass Media Mentalism
The magic of David Copperfield
In a 1992 TV show,
David Copperfield turned simple-minded mathematical
properties into something wonderful,
for an audience who was (skillfully) led to expect magical things to happen.
Copperfield first asks you to take N
steps forward and N steps back.
It doesn't matter what N is, does it?
Later, he says to go halfway around a circle in whichever
direction you choose (another type of irrelevant choice).
Regardless of the details of that show, it should be clear
that a magician can only make predictions about outcomes which do
not depend on the choices of his many spectators.
However, surprisingly many people want
to believe in some irrational explanation.
This is what really scares me.
Besides the visual effects and the drama,
the challenge in designing such a collective effect is also to devise
instructions that everyone can follow...
Grey Elephants in Denmark
Mental magic for classroom use... [Single-use collective mentalism]
The teacher tells the class that a crowd can be driven to think about the
same thing; very few people will escape the mental picture shared by all others...
Each student in the class is asked to think about a small number and is then
instructed to perform the following operations silently.
Double the number.
Add 8 to the result.
Divide the result by 2.
Subtract the original number...
Convert this into a letter of the alphabet. (1=A, 2=B, 3=C, 4=D, etc.)
Think of the name of a country which starts with this letter.
Think of an animal whose name starts with the country's second letter.
Think of the color of that animal...
The teacher then announces to a puzzled classroom that their collective thinking
must have gone wrong, since "there are no grey elephants in Denmark"...
Well, there are elephants in Denmark:
At this writing, the home of Kungrao (M), Surin (F) and Tonsak (F)
is the Copenhagen Zoo...
The trick works in most parts of the World,
but I wonder how many students from the Caribbeans would think
of an "ostrich in Dominica" instead.
The 5-Card Trick of Fitch Cheney How to reveal one of 5 random cards by showing the other 4 in order.
The 4! = 24 ways of showing 4 given cards in order would not be enough to differentiate
among the remaining 48 cards of the pack.
However, since we may choose what card is offered for guessing,
we have an additional choice among 5.
The resulting 120 possible courses of action are
more than enough to convey the relevant information.
Here's one practical way to do so:
Consider two cards of the same suit
(among 5 cards, at least one such pair exists).
Let's call them the base card and the hidden card,
in whichever order makes it possible to go from the base card
to the hidden card card by counting at most
6 steps clockwise on a circle of the 13 possible values.
(King is followed by Ace, Ace is followed by 2, 3, 4, etc.)
We offer the hidden card up for "guessing".
By revealing the base card first, we are telling the suit of the
hidden card and we also set the point where a count of up to 6 "clockwise"
steps is to begin to determine the hidden card.
The order in which the remaining 3 cards are presented can be used to reveal
this count, as there are 6 possible permutations of 3 given cards.
Using some agreed-upon ordering of the cards in a deck,
we hold a high card (H), a medium card (M) and a low card (L).
Some arbitrary code is used, like:
This trick is credited to Dr. William Fitch Cheney, Jr.
(Fitch the Magician, 1894-1974) who earned the first math Ph.D.
ever awarded by MIT (1927).
The puzzle is presented in the 1960 book of Wallace Lee
entitled Math Miracles (chapter 14, as quoted by
and was popularized by the magician Art Benjamin in 1986.
It was used in a 1994 job interview and subsequently appeared
on the rec.puzzles newsgroup, where Bob Vesterman posted the particular
presented above (1994-04-25).
In 1995, Robert Orenstein implemented Vesterman's encoding for online play at
(a dead link resuscitated from the 2007 archives,
courtesy of deadURL.com, on 2010-04-25).
For many years, that page was apologizing for having "temporarily" shut down its
(terse) interactive features, since 2002-08-15. Fortunately, that part was
in the same terse form, by Tom Ace,
an admirer of the trick who happens to be a software engineer.
[Generalization of the above]
Reveal n random cards (from a deck of d) by showing only k of them...
The previous article deals with k=4, n=5, d=52.
The case k=3, n=8, d=13 is called Devil's Poker :
The Devil chooses 5 cards
of a single suit and you present 3 of the remaining 8 cards one by one
to an Angel who must guess the Devil's hand,
using a prior convention between you and the Angel.
We have k! C(n,k) = n!/(n-k)! possible actions
to reveal one of C(d-k,n-k) compatible possibilities.
This task is only possible if the former exceeds the latter,
which means that n!(d-n)! must be greater than or equal
to (d-k)! .
That means k = n-1 in the case considered by Michael Kleber in the
In that case, the above inequality boils down to:
d < n! + n
Kleber goes on to show that this necessary condition
is sufficient to establish a working strategy.
The Kruskal Count
Kruskal's card trick.
This trick is attributed to the physicist
Martin David Kruskal
It illustrates a statistical feature which is amazing enough when
one first encounters it. Here's one way to present the effect:
If we use a regular deck of cards, we either remove the face cards or attribute
to them the same value (1) as aces.
Beforehand, a player chooses secretly a special number N from 1 to 10.
As the cards from the deck are revealed one by one, the player counts cards and considers
the N-th card revealed to be his new special number and keeps counting
N cards from that one, and so forth... All told, only a few cards are thus
singled out as special. The majority are not...
Yet, toward the end of the deck the dealer (the magician) can
confidently point out that one particular card is "special"...
The same trick can be demonstrated by a clever dealer who just looks at the cards
before dealing them and announces that a specific card (which may then be flipped
over and replaced in the deck) will turn out to be special.
play this version online
with a computer which (honestly) shuffles the deck.
Allow yourself to be baffled a few times before reading on...
Well, the explanation is simply statistical.
For the sake of simplicity, let's consider the
related case of an infinite sequence of cards, each bearing a positive integer n
with probability pn .
Two subsequences extracted with the above rules from an infinite sequence of digits
(0 to 9) will eventually coincide,
because if they coincide once they coincide forever (think about it).
Kruskal Paths to God.
(Martin Gardner, 1999)
In the U.S. Declaration of Independence,
all paths lead to God.
In the May 1999 issue
of Games Magazine,
Martin Gardner published the following
puzzle, among a small collection of some magic tricks with numbers.
It involves the first sentences of the US Declaration of Independence :
When in the Course of human Events, it becomes necessary for
one People to dissolve the Political Bands which have connected
amongthePowersoftheEarth, theseparateandequalStation to
whichthe Laws of Nature andof
Nature's God entitle them, a descent Respect to the Opinions of
Mankind requires that they should declare the causes which impel
them to the Separation.
You are instructed to pick any word in the first (red) section of the text.
Then, skip as many words as there are letters in your chosen word.
For example, if you picked the fourth word ("Course") you have to skip 6 words
("of human Events, it becomes necessary") to end up on the word "for"...
Iterate the same
process, by skipping as many words as there are letters in the successive
words you land on.
What's the first word you encounter in the last (green) section?
Answer: God. Always.
(The sequence would continue with the words: descent,
The "magic" is based on the Kruskal principle discussed above...
You will ultimately land on God
by starting with most words in the middle (yellow) section. The words that
do work have been underlined for you. You may check that this underlining is correct
by working it out (backwards) for yourself, starting with the last yellow words
("and", "of") which do land on God in one step.
As any word which leads to an underlined word gets underlined itself,
almost all words in the yellow section end up
being underlined. This includes the first 17 words of that yellow section.
Since all words of the red section have less than 17 letters, that
solid chunk of underlined words can't be jumped over and, therefore,
all paths starting in the red section will ultimately lead to the word "God"
in the green section.
(Actually, any word up to the word "Station" is a valid beginning of a sequence
which ends up on the word "God".)
Cyclic Stacked Deck
(Si Stebbins, 1898)
A predictable deck of cards that looks disordered.
We'll only discuss here the most famous system of its kind.
It's named after Si Stebbins (William Coffrin)
who presented it in 1898 as his own invention,
although it had been published as early as 1612.
Even earlier, Horatio Galasso wrote about a closely related system
in 1593 (just using a numeric progression by constant increments of 4,
instead of 3 for the Si Stebbins).
More complicated schemes of the same family feature four distinct increments
(one per suit; the only restriction being that their sum shouldn't
be a multiple of 13).
The ordering illustrated above and presented at right
is also revealed at the end of a
Jamal presenting two related magic tricks.
Such a deck can be cut many times, but not shuffled
(seasoned illusionists could use false shuffling ).
The value of the Nth card from the top (face down) is:
For example, if the bottom card is the jack of diamonds
(B=11, S=0) then
the tenth card (N=10) is a deuce
(since 11+3.10 is 41, which is equal to 2 modulo 13).
It's the deuce of hearts
because 0+10 is equal to 2 modulo 4.
One trick is to have a spectator cut the deck. You
secretly look at the bottom card and call the card
3 units higher in the next suit (from the
Clubs, Hearts, Spades, Diamonds) before revealing the top card.
Find a Specific Card by Counting :
Conversely, the position N of the card x of suit y
can be obtained from the Chinese Remainder Theorem
(a result N=0 would denote the bottom card).
Since 3N is x-B modulo 13, N is -4(x-B)
(HINT: -4x3 is -12 or +1 modulo 13).
With that value of N modulo 13 and the value of N modulo 4 (namely y-S)
we may apply our explicit formula
to solve the Chinese Remainder Problem and obtain N modulo 52 = 4x13,
The existence of such a formula makes the above far more flexible than
other stacking schemes
which lack arithmetic regularity
(including the infamous "Eight Kings CHaSeD" stack, which is merely based on
the mnemonic sentence:
"Eight Kings threa-ten to save nine fair ladies for one sick knave"
for the order 8K3T2795Q4A7J).
For example, if the bottom card is the jack of diamonds (B=11, S=0)
then the queen of hearts
(x=12, y=2) is at the following position (modulo 52):
N = 13 (2-0) - 4 (12-11) = 22
The king of spades is at
N = 13 (3-0) - 4 (13-11) = 31
The queen of diamonds is at
N = 13 (0-0) - 4 (12-11) = -4
The ace of clubs is at
N = 13 (1-0) - 4 (1-11) = 53
= 1 (Isn't it?)
Here's a quick method to arrange the deck as above:
Amazing last trick with a stacked deck
A nice way to reveal the Nth
card from a stacked deck.
The "Enigma" card trick
performed by Andy Field
Jay Mismag822 "The card-trick teacher"
Magic Age Cards (traditional set of 6 cards)
Tell the age of people (between 0 and 63) from the cards they pick.
Some traditional magic age cards
forgo the numbers 61, 62 and 63
(so that only 29 or 30 numbers per card are required, which are printed
in a 5 by 6 pattern,
with or without a star in the 30th position).
Full-range cards (with 32 numbers printed on each card)
are more satisfying. Here they are:
A spectator thinks of a number (up to 63) and tells you on what cards it is.
You call the exact number!
The weight of each card is the smallest number printed on it.
Any number is equal to the sum of the weights
of the cards it appears on.
52 = 32 + 16 + 4
This is just a straight consequence of binary
Each card actually shows all the numbers
which have a "1" in their respective binary representations at a given position.
The binary representation of 52 being 110100, it appears on 3 cards and is equal
to the sum of the 3 relevant powers of 2. Voilà.
Those cards are based on
In base 3, all numbers less than 81 are represented by 4 digits or less.
Each card shows the 54 numbers
which have a nonzero digit at a specific ternary position.
If the digit is 1, the number is listed in
If the digit is 2, the number is listed in
Ask 3 questions to find one card among 27 (or fewer).
This is a classic no-brainer. Deal any odd number of cards up to 27
in three equal piles (this means you're dealing 15, 21 or 27 cards,
according to taste). Ask what pile the chosen card belongs to
and collate the cards so the chosen pile is in the middle.
Deal and collate again in the same way.
Deal one last time. The chosen card will be in the middle
of the selected row. Reveal it in whatever dramatic way you like...
For a very fast effect, use just 9 cards and deal only twice
(although the underlying math for this 2-step trick becomes rather obvious).
The second step leaves 13 cards face-down, in the following order:
2, 6, 10, 14, 18, 22, 26, 30, 34, 38, 42, 46, 50.
The third step eliminates every other card and reverses the order again:
46, 38, 30, 22, 14, 6.
The final elimination leaves three cards face-down: 6, 22 and 38.
In other words, the first of the "Final Three" was initially at position
6 (i.e., with 5 face-down cards on top of it) and the other two
appeared thereafter at regular intervals of 15 intervening cards...
In the video presentation below, the number 15 is prominent and the number 5
is the result of subtracting 4 from 9 = 52-(10+1+15+1+15+1)...
There are also two "false cuts" to give an impression of randomness.
8 perfect faro shuffles leave a deck of 52 cards unchanged.
Even number of cards :
In a perfect faro shuffle of an even number of cards,
the deck is split into equal halves which are then interweaved.
There are two ways to do the interweaving.
In an out shuffle,
both the top card and the bottom card are unchanged
In a so-called in shuffle neither is (the top card
becomes second and the bottom card becomes next-to-last).
Out-shuffling 2n+2 cards is equivalent to in-shuffling
the inner 2n cards.
When the deck consists of an odd number of cards,
the deck is split into a pack of n+1 cards and a pack of n cards.
If the larger pack is on the bottom, then the bottom card always remains unchanged and
we are simply faced with a faro shuffling of only the 2n top cards.
So, only the case where the top pack is larger need be considered.
For an out shuffle that case is equivalent to an out shuffle
of 2n+2 cards (in an outshuffle of an even number of cards, the
bottom card stays in place). All told, the only case where the faro shuffling of
an odd number of cards does not reduce trivially to the shuffling of an even
number of cards is the following one:
In-shuffling of 2n+1 cards,
cutting n+1 cards from the top.
In such a shuffle, there's a pair of adjacent cards from
the middle of the pack which remain adjacent at the bottom of the pack after the
shuffle. It's much less regular than the other type of faro shuffling.
Yet, some patterns appear:
The number s of such shuffles needed to return a deck of
n cards to its original state is a complicated function of n.
Remarkably, if n is 3 units below a power of 2,
then s is a simple quadratic function of the exponent
(usually, the ratio s/n
is then much smaller than for any lesser values of n).
of s in-shuffles leaving n cards unchanged :
2 k (2k-1)
(2016-10-19) Counting in binary, using perfect shuffles.
In at most 7 shuffles, put the top card at any given position in the deck.
If n is the number of cards above a given card in the top half of
the deck, then the number of cards above that same card becomes:
2 n after an out-shuffle.
2 n + 1 after an in-shuffle.
Let's encode a sequence of perfect shuffles with a binary number Q where
a "0" bit corresponds to an out-shuffle and a "1" to an in-shuffle.
For example, an in-shuffle followed by two out-shuffles corresponds to
"100" (which is the binary expansion of the integer Q = 4).
If Q is less than the number of cards in the deck,
the above remark can be used to show
(by induction on the number of shuffles)
that a sequence of shuffles of code Q moves the topmost card Q places down
(i.e., after shuffling, there are Q cards above the card which was originally on top).
Two heaps of coins.
Equal numbers of heads. Always !
This classical trick can be done with ordinary coins
(each side is either heads or tails ).
However, it's simpler and more spectacular
with coins whose sides are easy to tell apart from a distance.
pieces (discs) are ideal for this:
They have a white side and a black one...
The Effect :
Put all the discs on the table, flip some of them over, shuffle them.
Ask your spectators to do the same.
Explain the difference between
shuffling the coins (sliding only) and flipping them over.
Now, turn around and tell the spectators to shuffle the coins behind
your back ("no flipping") then announce that you will
separate the whole mess into two heaps containing the same number of white discs
"using your sense of touch alone".
You do just that, very quickly (using both hands to go faster).
Then put your hands up in the air and turn around (in that order)
to check with the spectators that you've accomplished the improbable.
Do it several times and the improbable will look like the impossible.
The Secret :
Before turning your back, you count the number W
of white discs.
What you do behind your back is simply
pick W discs randomly and flip
them over as you put them flat on the table to form a
Why it works :
Consider any heap of W discs taken from a set that originally contained
W white discs and any number of black ones.
If x is the number of white discs in that heap,
then there are W-x black discs in it, which is
precisely the number of white discs that you left in the rest of the set.
If you flip over all the discs in your heap, there are now as many white discs
in it (namely, W-x) as in the rest of the set.
Gilbreath's principle: Simplified or full-blown version...
Some card patterns are preserved when a deck is shuffled by a spectator.
The basic principle featured here is named after Norman L. Gilbreath
(a computer scientist and amateur magician, born in March 1936)
who is a;so remembered for Gilbreath's conjecture which he
rediscovered and popularized, 80 years after its first formulation by
François Proth (1851-1879).
Gilbreath published a first version (concerning only the black or red colors of cards)
in The Linking Ring,
38, 5 (July 1958). Introducing himself as a math-major UCLA student,
Gilbreath named his effect "Magnetic Colors".
Although this had been known to some magicians before,
it was received as a major innovation by the Magic community.
So much so that, eight years later, an entire issue of The Linking Ring
(June 1966) would be devoted to Gilbreath magic.
In it, Gilbreatth himself presented a great generalization, now known as the
second principle of Gilbreath, on which we are focusing here...
The general principle is that a certain type of shuffling which ends with an
honest riffle-shuffle (performed by a spectator) will always
preserve one particular aspect of a cyclic deck with respect to
a separation of the deck into n equal classes
(e.g., 2 colors, 4 suits, 13 values): Even after such a shuffle,
every "slice" of n cards still contains one card of every class !
The Gilbreath Shuffle :
Starting from a cyclic deck (cut any number of times)
the first step of a proper Gilbreath shuffle consists
in separating the deck into two piles by dealing out one of them, thereby reversing
the order of the cards in it
(you may pretend that you're counting the cards to "make sure"
the piles are exactly even, although that's actually irrelevant).
The second step is to let a spectator riffle-shuffle those two piles together once.
Why it works :
After a Gilbreath shuffle, the situation is exactly identical to what would be obtained if we
had built the deck by successively picking a card either from the top or the bottom of the
original deck (at random).
Since slices of n cards are ordered alike at the top or the bottom of our cyclic
deck, we always obtain a full slice of different cards after n picks,
irrespective of the random choices made. (The same basic situation repeats after
a whole number of slices have been so obtained.)
In the case n = 2 (for black/red colors only,
as presented by Gilbreath in 1958)
it's an overkill to deal out one pile completely...
It suffices to make sure that the bottom cards in the two piles
have different colors (while preserving alternating colors).
This easy version is most often used by magicians
(see video clips in the footnotes below).
Here's my way to apply the full Gilbreath principle with a 52-card deck.
Slices of sizes 13 and 4 are used simultaneously in this example:
Effect (2015-03-09) :
Ask a spectator to take 12 cards off the top of the shuffled deck
and to secretly remove one of them. The other 11 cards are then exposed.
You stress that you clearly can't tell their card for sure without seeing
all the other 51 cards. Yet, you guarantee to call it with perfect accuracy,
by just peeking at the four top remaining cards... Then, you do just that!
As the deck is initially cyclically stacked,
the second Gilbreath principle applies:
The correct suit is the only suit which appears just 2 times (not 3)
among the first 11 cards shown.
The value of the hidden card is the only value missing from the first 12 cards revealed
(the 11 cards originally shown and the first card turned over from the top of the remaining deck).
Yes, only the top card is needed; the extra ones just help conceal the secret!
Also, the first 11 cards allow you to determine the correct suit and leave a choice of only two values.
The correct value is whichever of those two differs from the value of the
top card (to be revealed next).
Thus, you can be ready to call the spectator's card very fast
when the top cards are turned over (all at once). This speed-flourish enhances the effect's impact.
Divination by counting (from any 52-card pack).
A self-working effect, originally designed by Paul A. Lelikis c. 1970.
This trick works by relating the number of cards in several piles to the values of their top cards.
The video by Brian Brushwood (link in the footnote)
demonstrates the effect and shows how
to perform it (same thing really, for this particular effect)
but doesn't provide an explanation... Here's one:
Well, in the last stage of the trick, each of the three face-down piles on the table contains
14-n cards, where n is the value (between 1 and 13) of the top card.
If you deal out the number of cards indicated by that top card for two piles,
each of them will have consumed a total of 14 cards. Therefore, from the original 52 cards,
24 cards are left (52-28) which are either in your hand or in the remaining pile
of 14-n cards, where n is the value of the face-down top card, which you
have to determine...
So, if you have removed 10 cards from your hand at the outset,
there's a total of 14 cards left. As 14-n of those are in the "unknown" pile,
you are holding exactly n cards.
Counting them reveals the value of the pile's top
Many variants of the same mathematical trick start with the construction of several piles
containing 14-n cards
( n being the value of each pile's own top card).
The key point is that, when one such pile is finally chosen,
the number of cards outside of it is simply 38+n.
Thus, the real challenge in designing such an effect is to come up with some interesting method
to get rid of 38 cards before the final count (in a sufficiently obscure way).
A card-counting trick from
Stu Ungar (1953-1998) Effect: Tell the last card of a deck when all the others have been shown.
The secret is to assign a unique number to each card an know what the total for the whole deck is.
Mentally keep the running total of all the cards which have been shown.
When only one card remains, its number is obtained by subtracting that total from
the known total for the whole deck.
If we use numbers from 1 to 52, the total for the whole deck is:
(52+1) 52 / 2 = 1378
The formula behind that calculation was discovered by
Gauss when he was seven years old.
In practice, it's easier to assign cards in each suit values from 0-12,
20-32, 40-52 and 60-72. The grand total for that scheme is 1872.