login
A377280
Given n cards, each time you reversing the order of the top 1, 2, 3, ..., n-1, n cards, then repeat reversing 1, 2, 3, ... cards. Do reversing at least once. the minimum number of steps required to return all the cards to their original position.
1
1, 4, 9, 12, 25, 36, 28, 32, 81, 60, 121, 120, 117, 196, 75, 80, 204, 324, 228, 200, 147, 264, 529, 504, 200, 676, 540, 252, 841, 900, 186, 192, 1089, 748, 1225, 324, 740, 1140, 1521, 1080, 1681, 336, 1204, 484, 540, 460, 1692, 1152, 735, 2500, 2601, 624, 2809, 972, 1980, 784, 2508, 696, 1416, 3300
OFFSET
1,2
COMMENTS
The sequence is only restored after one of the full length n reversal, so a(n) >= n.
The process of reversing blocks from 1 to n corresponds to the order transformation of numbers in sequence A130517.
FORMULA
a(n) = n * A003558(n).
EXAMPLE
For example, using "abc" to represent three cards, the card positions at the end of each step are: abc, bac, cab, cab, acb, bca, bca, cba, abc. Therefore, it takes 9 steps. If there are 4 cards "abcd", the sequence of changes is: abcd, bacd, cabd, dbac, dbac, bdac, adbc, cbda, cbda, bcda, dcba, abcd, so it takes 12 steps
PROG
(PARI) A377280(n)=my(M=Mod(2, 2*n+1), o=znorder(M)); if(o%2==0&&M^(o/2)==-1, n*o/2, o*n) \\ Kevin Ryde
(Python)
from sympy.ntheory import n_order
def A377280(n):
modular = 2*n + 1
order = n_order(2, 2*n+1)
if order % 2 == 0 and pow(2, order//2, modular) == modular - 1:
return (order//2) * n
else:
return order * n # after Kevin Ryde
CROSSREFS
Sequence in context: A212875 A069082 A344415 * A297414 A076794 A254520
KEYWORD
nonn
AUTHOR
Youhua Li, Oct 22 2024
STATUS
approved