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.

A070864 a(1) = a(2) = 1; a(n) = 2 + a(n - a(n-1)).

Original entry on oeis.org

1, 1, 3, 3, 3, 5, 3, 5, 5, 5, 7, 5, 7, 5, 7, 7, 7, 9, 7, 9, 7, 9, 7, 9, 9, 9, 11, 9, 11, 9, 11, 9, 11, 9, 11, 11, 11, 13, 11, 13, 11, 13, 11, 13, 11, 13, 11, 13, 13, 13, 15, 13, 15, 13, 15, 13, 15, 13, 15, 13, 15, 13, 15, 15, 15, 17, 15, 17, 15, 17, 15, 17, 15, 17, 15, 17, 15, 17, 15
Offset: 1

Views

Author

N. J. A. Sloane, May 19 2002

Keywords

Examples

			If k = 4, a(4^2+1) = a(17) = a(16) = 2*4 - 1 = 7, a(15) = 2*4 - 2 - (-1)^1 = 7, a(14) = 2*4 - 2 - (-1)^2 = 5, a(13)=7, a(12)=5, a(11)=7.
		

References

  • S. Wolfram, A New Kind of Science, Wolfram Media, 2002; p. 129.

Crossrefs

Cf. A004001.

Programs

  • Mathematica
    a[1]=a[2]=1; a[n_]:= a[n]= 2 + a[n -a[n-1]]; Table[a[n], {n,80}]
  • Sage
    @CachedFunction
    def a(n): # A070864
        if (n<3): return 1
        else: return a(n - a(n-1)) + 2
    [a(n) for n in (1..80)] # G. C. Greubel, Mar 28 2022

Formula

Conjecture. Let a(1)=a(2)=1 and for n > 2 let k = floor(sqrt(n+1))-1 and d=n-k(k+2). Then, if (d is 0, 1, or 2) OR (d=0 mod 2), a(n)=2k+1; otherwise a(n)=2k+3. This has been verified for n <= 15000. Thus the asymptotic behavior appears to be a(n) ~ floor(sqrt(n+1)). - John W. Layman, May 21 2002
By induction, a(1)=a(2)=1, a(3)=a(4)=a(5)=3 and for k >= 3 we obtain the following formulas for the 2k-1 consecutive values from a(k^2-2k+2) up to a(k^2+1): a(k^2+1) = a(k^2) = 2k-1, if 1 <= i <= 2k-3 then a(k^2-i) = 2k-2-(-1)^i, hence asymptotically a(n) ~ 2*sqrt(n). - Benoit Cloitre, Jul 28 2002
a(n) = 2*floor(n^(1/2)) + r where r is in {-1,1}. More precisely, let g(n) = round(sqrt(n)) - floor(sqrt(n+1)-1/sqrt(n+1)); then for n >= 1 we get: a(2*n) = 2*floor(sqrt(2*n)) - 2*g(ceiling(n/2)) + 1 and something similar for a(2*n+1). - Benoit Cloitre, Mar 06 2009
a(n) = 2*floor(n^(1/2)) - (-1)^(n + ceiling(n^(1/2))) for n > 0. - Branko Curgus, Feb 10 2011

Extensions

More terms from Jason Earls, May 19 2002