login
a(1) = a(2) = 1; a(n) = 2 + a(n - a(n-1)).
3

%I #42 May 09 2022 08:35:45

%S 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,

%T 11,9,11,11,11,13,11,13,11,13,11,13,11,13,11,13,13,13,15,13,15,13,15,

%U 13,15,13,15,13,15,13,15,15,15,17,15,17,15,17,15,17,15,17,15,17,15,17,15

%N a(1) = a(2) = 1; a(n) = 2 + a(n - a(n-1)).

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

%H T. D. Noe, <a href="/A070864/b070864.txt">Table of n, a(n) for n = 1..1000</a>

%H Nick Hobson, <a href="/A070864/a070864.py.txt">Python program for this sequence</a>

%H Eric Weisstein's World of Mathematics, <a href="http://mathworld.wolfram.com/WolframSequences.html">Wolfram Sequences</a>

%H <a href="/index/Ho#Hofstadter">Index entries for Hofstadter-type sequences</a>

%F 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

%F 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

%F 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

%F a(n) = 2*floor(n^(1/2)) - (-1)^(n + ceiling(n^(1/2))) for n > 0. - _Branko Curgus_, Feb 10 2011

%e 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.

%t a[1]=a[2]=1; a[n_]:= a[n]= 2 + a[n -a[n-1]]; Table[a[n], {n,80}]

%o (Sage)

%o @CachedFunction

%o def a(n): # A070864

%o if (n<3): return 1

%o else: return a(n - a(n-1)) + 2

%o [a(n) for n in (1..80)] # _G. C. Greubel_, Mar 28 2022

%Y Cf. A004001.

%K nonn,easy

%O 1,3

%A _N. J. A. Sloane_, May 19 2002

%E More terms from _Jason Earls_, May 19 2002