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.

A340134 a(n+1) = a(n-2*a(n)) + 1, starting with a(1) = a(2) = 0.

Original entry on oeis.org

0, 0, 1, 1, 1, 2, 1, 2, 2, 2, 3, 2, 3, 2, 3, 3, 3, 4, 3, 4, 3, 4, 3, 4, 4, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 5, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 6, 6, 7, 6, 7, 6, 7, 6, 7, 6, 7, 6, 7, 6, 7, 7, 7, 8, 7, 8, 7, 8, 7, 8, 7, 8, 7, 8, 7, 8, 7, 8, 8, 8, 9, 8, 9, 8, 9
Offset: 1

Views

Author

Rok Cestnik, Dec 29 2020

Keywords

Examples

			a(3) = a(2-2*a(2))+1 = a(2)+1 = 1.
a(4) = a(3-2*a(3))+1 = a(1)+1 = 1.
a(5) = a(4-2*a(4))+1 = a(2)+1 = 1.
a(6) = a(5-2*a(5))+1 = a(3)+1 = 2.
		

Crossrefs

For a(n+1) = a(n-a(n)) + 1, starting with a(1) = 0, see A003056.

Programs

  • Mathematica
    Table[Floor[Sqrt[n-1]] + ((-1)^(n+Floor[Sqrt[n]])-1)/2,{n,87}] (* Stefano Spezia, Dec 29 2020 *)
  • Python
    a = [0, 0]
    for n in range(1, 1000):
        a.append(a[n-2*a[n]]+1)

Formula

a(n) = floor(sqrt(n-1)) + ((-1)^(n+floor(sqrt(n)))-1)/2.

Extensions

More terms from Stefano Spezia, Dec 29 2020