%I #15 Mar 29 2022 03:40:45
%S 1,1,2,2,2,3,3,4,3,4,4,4,5,4,6,5,6,6,7,6,7,6,7,7,7,8,8,9,7,9,7,10,8,
%T 11,8,11,9,10,10,11,10,11,10,11,11,11,12,11,13,12,13,13,14,12,14,11,
%U 15,13,16,12,14,12,15,14,14,14,15,16,15,16,16,15,17,16,16,16,16,17,17,18
%N a(1) = a(2) = 1; a(n) = a(a(n-1)) + a(n+1 - 2*a(n-1)).
%D S. Wolfram, A New Kind of Science, Wolfram Media, 2002; p. 129.
%H G. C. Greubel, <a href="/A070868/b070868.txt">Table of n, a(n) for n = 1..10000</a>
%H Nick Hobson, <a href="/A070868/a070868.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 a(n) = a(a(n-1)) + a(n+1 -2*a(n-1)), with a(1) = a(2) = 1.
%t a[1]=a[2]=1; a[n_]:= a[n]= a[a[n-1]] +a[n+1 -2*a[n-1]]; Table[a[n], {n,80}]
%o (Sage)
%o @CachedFunction
%o def a(n): # A070868
%o if (n<3): return 1
%o else: return a(a(n-1)) + a(n+1 -2*a(n-1))
%o [a(n) for n in (1..90)] # _G. C. Greubel_, Mar 28 2022
%Y Cf. A070881.
%K nonn,easy
%O 1,3
%A _N. J. A. Sloane_, May 19 2002
%E More terms from _Robert G. Wilson v_, May 20 2002