For Martin Gardner, the link between mathematics and magic is essential, since it shows how abstract concepts can translate into a magical experience for the spectator. A tireless seeker of magic, he is as interested in studying the great classics as in creating new tricks, particularly for their mathematical interest: they show how simple principles can produce powerful effects. In his book Mathematics, Magic and Mystery, published in 1956, Martin Gardner explores the famous "27-card trick", a true pillar of the history of card magic. This trick, regarded as a timeless classic, owes its fame to its apparent simplicity and its mathematical depth. Gardner considers it "one of the most interesting tricks there is". Using an ingenious principle of sorting and dealing, it can pinpoint the card chosen by the spectator with uncanny precision. This universal character makes it a must-know classic for magicians and logic enthusiasts alike.
The 27-card trick ------------------
Here is how the trick works. The magician shows the spectator a deck of 27 different cards; the spectator picks one and memorizes it, without revealing its identity. The spectator is also asked to choose a number n between 1 and 27. The magician shuffles the cards and then deals them into three piles, as if dealing to three players, except that the cards are face up. The spectator then indicates which pile contains their card. The magician gathers all the cards and repeats the process two more times: dealing into three piles and indicating which pile contains the card. Finally, the magician reassembles the stack of 27 cards, then counts off the cards up to the nth, which turns out to be the card the spectator chose.

Card Tricks by Jean Siméon Chardin, circa 1735.