Yamagishi Complexity Torus LabYamagishi Lab

[Paper 626] Eight Perfect Shuffles Restore 52 Cards, While Seven Random Riffles Nearly Mix Them

Abstract

Splitting a deck in half and interleaving one card at a time from each half is a perfect shuffle. One that keeps the top card on top is an out-shuffle; one that makes the top card second is an in-shuffle. How many shuffles restore the order, and how many random riffles of the same kind mix it, are counted. No new theorem or law is claimed.

First, 52 cards return after $8$ out-shuffles or $52$ in-shuffles——shuffling and counting, $8$ out-shuffles and $52$ in-shuffles restored the order (Section 2).

Second, the count is the order of $2$——the number of out-shuffles is how many powers of $2$ it takes for the remainder on division by $n-1$ first to be $1$; for in-shuffles, on division by $n+1$. For every even deck from $4$ to $100$ cards it matched the actual shuffling. $50$ cards need $21$ out-shuffles and $8$ in-shuffles, $64$ cards $6$ and $12$: one card more or less changes the count greatly (Section 2).

Third, the top card can be sent anywhere——writing the target position in binary and doing an in-shuffle for each $1$ and an out-shuffle for each $0$ from the top digit, the top card was sent to every position $0$ to $51$ of $52$ cards within $6$ shuffles (Section 3).

Fourth, and this is the core. The same interleaving restores the order when perfect and mixes it when random——in a riffle with a random cut and random drops (the Gilbert--Shannon--Reeds model), the distance from uniform (total variation) stays $1.000000$ up to $4$ riffles, then falls to $0.923733$ at $5$, $0.613550$ at $6$, $\mathbf{0.334061}$ at $7$ and $0.167159$ at $8$. In the same number that the perfect shuffle restores the order, random riffles nearly finish mixing it (Section 4).

Keywords: perfect shuffle, faro shuffle, multiplicative order of 2, riffle shuffle, card mixing.

Scope (what is not claimed)

No new theorem or law is claimed——that the number of perfect shuffles is set by the order of $2$ (the paper by Diaconis, Graham and Kantor of $1983$ and others) and the formula for how random riffles mix (Bayer and Diaconis, $1992$) are known. Card-trick technique is not discussed——whether a perfect shuffle can be done by hand is not treated. One model of random riffles is used——whether human shuffling follows this model is not treated. Relation to earlier papers: Paper 603 followed the remainders of powers of $2$ on division by $561$ to examine Fermat’s test——here the number of powers of $2$ before the remainder on division by $51$ returns to $1$ is the number of shuffles before the cards return. What is added is matching the route of actual shuffling with the order of $2$ for decks of $4$ to $100$ cards, confirming the binary procedure for sending the top card over all $52$ positions, and placing the separator on fixed versus random shuffling and setting out the distances for random riffles.

1. Notation and the Question

Setting: a deck of $n$ cards ($n$ even) is split into upper and lower halves and interleaved one card at a time. If the first card of the upper half ends on top it is an out-shuffle; if the first card of the lower half does, an in-shuffle. In an out-shuffle the top and bottom cards stay, and every other card moves from position $i$ to $2i$ modulo $n-1$; in an in-shuffle a card moves from position $i$ (counting from $1$) to $2i$ modulo $n+1$.

Question: how many shuffles restore the order, and how many random versions of the same shuffle mix the deck?

2. Shuffles to Return

Computation 2.1: the number of shuffles until the order returned was compared with the number of powers of $2$ until the remainder first equals $1$ (the order of $2$).

cardsout (order of $2$ mod $n-1$)in (order of $2$ mod $n+1$)
$8$$3$$6$
$10$$6$$10$
$32$$5$$10$
$50$$21$$8$
$52$$8$$52$
$54$$52$$20$
$64$$6$$12$

For every even deck from $4$ to $100$ cards, the actual shuffles and the order of $2$ agreed.

Observation 2.2 52 cards need only $8$ out-shuffles because $2^8=256$ leaves remainder $1$ on division by $51$. An in-shuffle divides by $53$, where the remainder first returns to $1$ at $2^{52}$, so it takes $52$——keeping the top card on top or putting it second divides by $51$ or $53$, and splits the counts into $8$ and $52$.

3. Sending the Top Card

Computation 3.1: the target position $p$ ($0$ to $51$) was written in binary, and from the top digit an in-shuffle was done for each $1$ and an out-shuffle for each $0$. In all $52$ cases the top card arrived at position $p$. Since $51$ has $6$ binary digits, at most $6$ shuffles are needed.

Observation 3.2 an in-shuffle doubles the top card’s position and adds $1$; an out-shuffle doubles it. So it is the same as writing binary digits one at a time from the top——a perfect shuffle is merely doing binary arithmetic with cards.

4. Random Riffles

Computation 4.1: for a random riffle with a binomial cut and each card dropped from a half with probability proportional to its remaining size (the Gilbert--Shannon--Reeds model), the distance of $52$ cards from uniform after $k$ riffles (total variation) was computed exactly by the formula of Bayer and Diaconis.

riffles$4$$5$$6$$7$$8$$9$$10$$12$
total variation$1.000000$$0.923733$$0.613550$$\mathbf{0.334061}$$0.167159$$0.085420$$0.042946$$0.010755$

Observation 4.2 this is the core: the same interleaving restores the order when perfect and mixes it when random. Perfect shuffles restore $52$ cards in $8$. Random riffles keep traces of the original order up to $4$ (distance $1.000000$), and mix to $0.334061$ at $7$ and $0.167159$ at $8$——what separates them is not the number of shuffles but whether the shuffle is fixed or random.

5. The Separator

Observation 5.1 the separator is whether the shuffle is fixed or random. If fixed, the rearrangement repeats one permutation and must eventually return. If random, the rearrangement differs each time and the order approaches uniform——and even among fixed shuffles, out versus in changes the divisor and the count from $8$ to $52$.

Observation 5.2 beside Paper 603. Paper 603 followed the remainders of powers of $2$ on division by $561$ and showed that $561$ passes the test though not prime——here the same remainders of powers of $2$ count the shuffles until the cards return. $53$ is prime and the order of $2$ reaches the maximum $52$, so in-shuffles take $52$.

Observation 5.3 what is not said. Card-trick technique and whether human shuffling follows the random-riffle model are not treated——what is shown is the agreement of actual shuffling with the order of $2$, the binary procedure for sending cards, and the distances for random riffles.

6. Roll Call and Closing

  1. 52 cards return in $8$ out-shuffles (Computation 2.1): $2^8$ leaves $1$ modulo $51$.
  2. $52$ in-shuffles (Computation 2.1): because it divides by $53$.
  3. agreement with the order of $2$ for $4$ to $100$ cards (Computation 2.1): two routes.
  4. $50$ cards need $21$ out-shuffles (Computation 2.1): the count changes greatly with size.
  5. binary sends the top card anywhere (Computation 3.1): within $6$ shuffles.
  6. in doubles and adds $1$, out doubles (Observation 3.2): writing binary digits.
  7. random riffles reach $\mathbf{0.334061}$ at $7$ (Computation 4.1): nearly mixed.
  8. $1.000000$ up to $4$ (Computation 4.1): traces remain.
  9. perfect returns, random mixes (Observation 4.2): the core.
  10. remainders of powers of $2$ count the shuffles (Observation 5.2): Paper 603.

Closing: Splitting the deck in half and interleaving, $52$ cards return to their order after $8$ out-shuffles or $52$ in-shuffles. The count is the order of $2$——the number of powers of $2$ before the remainder on division by $51$ or $53$ returns to $1$, matching the actual shuffles for every deck from $4$ to $100$ cards. The top card can be sent anywhere by choosing in and out by its binary digits. The same shuffle returns the order when perfect and mixes it when random——random riffles bring the distance from uniform to $0.334061$ at $7$ and $0.167159$ at $8$. The separator is whether the shuffle is fixed or random. Placed among the earlier papers——the remainders of powers of $2$ from Paper 603 here count how often the cards return. To be honest——neither card tricks nor whether people shuffle like the model are entered.

References

  1. Bayer, D., & Diaconis, P. (1992). Trailing the dovetail shuffle to its lair. The Annals of Applied Probability.
  2. Diaconis, P., Graham, R. L., & Kantor, W. M. (1983). The mathematics of perfect shuffles. Advances in Applied Mathematics.
  3. Yamagishi, Y. (2026). 561 Passes Fermat’s Test for Every Base Coprime to It [Paper 603]. Zenodo. 10.5281/zenodo.23014433

Reference

Yamagishi, Y. (2026). Eight Perfect Shuffles Restore 52 Cards, While Seven Random Riffles Nearly Mix Them [Paper 626]. YOI: https://www.yamagishiyuuki.com/yoi/626
DOI: 10.5281/zenodo.23014539
ORCID: 0009-0006-8587-3450

PDF (English) · PDF (Japanese) · Date proof of the English PDF (OpenTimestamps .ots) · SHA256SUMS

The record page for this paper (in Japanese, with the PDFs in each language and the date proof): YOI 626. This paper is a preprint and has not been peer reviewed.