login
A395069
Number of steps to return a deck of n cards to its original state (original order and all cards face up) under a cyclic signed prefix-reversal shuffle: repeatedly flip the top 1 card, then the top 2, ..., then all n cards, cycling back to 1 until the initial state is restored.
0
2, 8, 9, 24, 50, 72, 28, 64, 162, 60, 121, 240, 234, 392, 75, 160, 204, 648, 228, 400, 294, 264, 529, 504, 200, 1352, 540, 504, 1682, 1800, 186, 384, 2178, 748, 1225, 324, 740, 1140, 1521, 2160, 3362, 336, 1204, 484, 540, 460, 1692, 2304, 1470, 5000, 2601, 624
OFFSET
1,1
COMMENTS
Starting with a deck of n cards labeled 1..n, all face up, in their natural order from top to bottom, one full step consists of n sub-steps. In sub-step k (k = 1, 2, ..., n), the top k cards are physically reversed as a block: their order is inverted and each card is flipped (face-up becomes face-down and vice versa). This constitutes one full step. The sequence a(n) counts how many full steps are required for the deck to return exactly to the initial state: same order and all cards face up.
FORMULA
a(n) = n * A002326(n). - Sean A. Irvine, Apr 20 2026
EXAMPLE
Example for n=3, starting with deck [1u, 2u, 3u]
(u=face up, d=face down, top of deck is leftmost):
Step 1:
k=1: flip top 1 -> [1d, 2u, 3u]
k=2: flip top 2 -> [2d, 1u, 3u]
k=3: flip top 3 -> [3d, 1d, 2u]
Step 2:
k=1: flip top 1 -> [3u, 1d, 2u]
k=2: flip top 2 -> [1u, 3d, 2u]
k=3: flip top 3 -> [2d, 3u, 1d]
Step 3:
k=1: flip top 1 -> [2u, 3u, 1d]
k=2: flip top 2 -> [3d, 2d, 1d]
k=3: flip top 3 -> [1u, 2u, 3u] = initial state
Thus a(3) = 3 full steps = 9 sub-steps.
PROG
(Python)
def a(n):
# Each card: [id, face] where face 1=up, 0=down
deck = [[i, 1] for i in range(n)]
steps = 0
while True:
for k in range(1, n + 1):
packet = deck[:k]
packet.reverse()
for card in packet:
card[1] = 1 - card[1]
deck = packet + deck[k:]
steps += 1
if all(deck[i][0] == i and deck[i][1] == 1 for i in range(n)):
return steps
print([a(n) for n in range(1, 21)])
CROSSREFS
KEYWORD
nonn
AUTHOR
Fabio Longo, Apr 10 2026
EXTENSIONS
More terms from Sean A. Irvine, Apr 20 2026
STATUS
approved