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.

A261923 Number of steps to reach 0, starting at n, and iteration the map x -> A261922(x).

Original entry on oeis.org

0, 1, 2, 1, 2, 2, 3, 1, 2, 2, 2, 3, 3, 3, 3, 1, 2, 2, 2, 3, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 1, 2, 2, 2, 3, 2, 2, 3, 3, 2, 2, 2, 3, 2, 3, 3, 3, 3, 3, 3, 3, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 1, 2, 2, 2, 3, 2, 2, 3, 3, 2, 2, 2, 4, 3, 2, 3, 3, 2, 2, 2, 4, 2, 2
Offset: 0

Views

Author

N. J. A. Sloane, Sep 17 2015

Keywords

Examples

			13 -> 4 -> 3 -> 0, which takes 3 steps to reach 0, so a(13)=3.
		

Crossrefs

Programs

  • Haskell
    a261923 n = fst $ until ((== 0) . snd)
                            (\(step, x) -> (step + 1, a261922 x)) (0, n)
    -- Reinhard Zumkeller, Sep 17 2015
    
  • PARI
    a(n) = if (n==0, 0, my(k=1, x=A261922(n)); while (x, x=A261922(x); k++); k); \\ Michel Marcus, Sep 20 2023
    
  • Python
    def f(n): b=bin(n)[2:]; return next(k for k in range(2**len(b)) if bin(k)[2:] not in b)
    def a(n): return 0 if n == 0 else 1 + a(f(n))
    print([a(n) for n in range(99)]) # Michael S. Branicky, Sep 21 2023

Formula

a(A262279(n)) = n. - Reinhard Zumkeller, Sep 17 2015