Mathematical Card Tricks
Binary searches and sorts form the basic for many fine card routines, including the next forcing and prediction trick, which utilizes the so-called down under deal: a packet of cards is dealt out by first dealing a card onto the table, then one underneath the cards remaining in your hand, and so on, until only one card remains.
Method: Method: You must know the top card on the deck at the outset. This can be peeked at ahead of time, and some distracting (but harmless) riffle shuffles executed. Next, you need to compute twice the difference between the number called out and the highest power of two which is strictly less than it. E.g., if fourteen is called out, compute 2 * (14 - 8) = 12. Now deal out that many cards casually into a pile, thus reversing their order. Gather up the cards while feigning poor memory, saying ``How many did you say? Oh, fourteen,'' and scoop the extra two cards off the deck and place them beneath the cards in your hard. In this way you now have the card you know in the twelfth position in a packet of fourteen cards. If, on the other hand, sixteen is called out, simply deal that number into a pile. In either case, hand this packet to the victim, and carefully direct the down under dealing. The last card is guaranteed to be the original top card.
There are other, less obvious, ways to achieve the goal of the false count above which will likely go unnoticed by your audience -- just use your imagination.
Mathematics: Everything becomes clearer if we convert to base 2. Suppose the called out number is 1abc...e in base 2. An exercise for the reader is to show that the down under deal from a packet of 1abc...e cards always leaves as last card the card which started in position abc...e0, unless the number of cards in the packet is exactly a power of two; and in that case the down under deal ends up with the original bottom card in the packet. Now if 1abc...e is not a power of two, the highest power of 2 strictly less than it is 1000...0, and when this is subtracted from 1abc...e we get abc...e. Twice that is abc...e0. On the other hand, if 1abc...e = 1000...0 is a power of two, the next highest power of two is 100...0 (one less zero), the difference is also 100...0, and twice the difference gets back the total number of cards in the packet. Either way, the down-under deal will end up with the card you peeked at.
Source: Gardner mentions learning the basic idea behind this one from Mel Stover in The Unexpected Hanging and Other Mathematical Diversions (Simon and Schuster, 1969, republished by Univ. of Chicago Press, 1991), and credits magician John Scarne with the above presentation. He also mentions a Bob Hummer version from 1939, and describes several variations on the theme due to Sam Schwartz and others.
Bonus points: An easier trick, dating back to the 1920s, which uses the fact that each number is a sum of powers of 2, can be found in Gardner's Mathematics Magic and Mystery (Dover, 1956), listed as ``Findley's Four-Card Trick,'' and in Simon's Mathematical Magic (Dover, 1964), where it appears in the guise of ``The Spirit Mathematician.''