A216476 Number of iterations of the "Oware" operation until the initial position n is reproduced.
1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 4, 3, 6, 10, 12, 4, 8, 18, 6, 4, 3, 6, 10, 12, 4, 8, 18, 6, 11, 3, 2, 10, 12, 4, 8, 18, 3, 11, 20, 6, 10, 12, 4, 8, 18, 6, 11, 20, 18, 10, 12, 2, 8, 18, 6, 11, 4, 18, 28, 12, 4, 8, 18, 3, 11, 20, 6, 28, 5, 4, 8, 18, 2, 11, 20, 18, 28, 5, 10, 8, 18, 6, 11, 20, 18, 28, 5, 10, 12, 18
Offset: 1
Examples
The Oware operation on 541 consists of taking the 5 (and making this digit zero) and then increase 5 times the subsequent digits in a cyclic manner : 4->5; 1->2; 0->1; 5->6; 2->3, which yields 163, the '3' being the new starting digit (or "pivot") for the next iteration. Note that after 41 iterations, the number 541 is reproduced, but the current "pivot" is not the first but the last. Only 10 iterations later, one gets again the number 541 with now the first digit being the "pivot". Thus, a(541) = 51. See the link for further examples.
Links
- Charlie Neder, Table of n, a(n) for n = 1..1000
- E. Angelini, Oware (with integers), Sept. 2012.
- E. Angelini, Oware (with integers) [Cached copy, with permission]
Programs
-
PARI
A216476(n)={my(o=n=Vecsmall(Str(n)),c,p=Mod(0,#n));until(!p & o==n,c++;for(i=1,n[lift(p)+1]-n[lift(p)+1]=48,n[lift(p++)+1]++));c} /* The ++ on a Vecsmall component yields a segfault on PARI versions < 2.4.4. One can replace Vecsmall(...) -> eval(Vec(...)) and 48 -> 0. */
-
Python
for n in range(1, 1001): digits = [int(i) for i in str(n)] piv, step, arr = 0, 0, digits.copy() while not (step and piv == 0 and arr == digits): hand = arr[piv] arr[piv] = 0 for k in range(hand): piv = (piv+1)%len(arr) arr[piv] += 1 step += 1 print(n, step) # Charlie Neder, Feb 26 2019
Comments