cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A216476 Number of iterations of the "Oware" operation until the initial position n is reproduced.

Original entry on oeis.org

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

Views

Author

Eric Angelini and M. F. Hasler, Sep 11 2012

Keywords

Comments

The "Oware" operation on n consists of replacing a given "pivot" digit by 0 and then "distribute" the (former) value of that digit on all digits, by increasing by 1 the following digits, "wrapping" around to start over with the first digit after the last has been increased. The first iteration starts with the first digit, but on subsequent iterations one starts with the last digit that has been increased during the previous iteration. "Initial position" means not only the same digits (i.e., the number n) are reproduced, but also the current "pivot" must again be the initial (first) digit.

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.
		

Crossrefs

Cf. A216502 (indices of record values), A306564.

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