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
KEYWORD
nonn
AUTHOR
Youhua Li, Oct 22 2024
STATUS
approved