An in shuffle is a type of perfect shuffle done in two steps:
- Split the cards exactly in half (a bottom half and a top half) and then
- Interweave each half of the deck such that every-other card came from the same half of the deck.
If this shuffle moves the top card to be 2nd from the top then it is an in shuffle, otherwise it is known as an out shuffle.
For simplicity, we will use a deck of six cards.
The following shows the order of the deck after each in shuffle. Notice that a deck of this size returns to its original order after 3 in shuffles.
For a standard deck of 52 playing cards, the number of in shuffles required to return the deck to its original order is 52. This phenomenon occurs because 2 is a primitive root modulo 53, the number of cards plus one. In general, for a deck of n cards, the number of in shuffles required to return the deck to its original order is n when 2 is a primitive root modulo n + 1 and n + 1 is prime, and is smaller than n otherwise. According to Artin's conjecture on primitive roots, it follows that there are infinitely many deck sizes which require the full set of n shuffles.
- Diaconis, P.; R.L. Graham; W.M. Kantor (1983). "The mathematics of perfect shuffles" (PDF). Advances in Applied Mathematics. 4 (2): 175–196. doi:10.1016/0196-8858(83)90009-X.
- Kolata, Gina (April 1982). "Perfect Shuffles and Their Relation to Math". Science. 216 (4545): 505–506. doi:10.1126/science.216.4545.505. PMID 17735734.
- Morris, S.B., S. Brent (1998). Magic Tricks, Card Shuffling and Dynamic Computer Memories. The Mathematical Association of America. ISBN 0-88385-527-5.
- Jain, Peiyush (May 2008). "A simple in-place algorithm for in shuffles". arXiv: .