login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

a(0)=2, a(1)=1, a(2)=0; thereafter a(n) = a(n-1-a(n-1))+a(n-2-a(n-2)) unless a(n-1) <= n-1 or a(n-2) <= n-2 in which case the sequence terminates.
8

%I #25 Oct 02 2024 06:47:46

%S 2,1,0,2,1,3,2,1,3,5,4,3,5,4,6,8,4,6,8,7,9,8,7,12,11,7,12,14,10,12,14,

%T 10,12,17,13,12,20,16,12,20,19,15,20,19,18,23,19,21,26,19,21,26,19,24,

%U 29,19,27,32,19,27,32,22,30,32,22,30,32,25,33,32,28,36,32,31,39,32,31,42,35,31,45,38,31,45,38,31,48,41,31,51,44,31,51,47,34

%N a(0)=2, a(1)=1, a(2)=0; thereafter a(n) = a(n-1-a(n-1))+a(n-2-a(n-2)) unless a(n-1) <= n-1 or a(n-2) <= n-2 in which case the sequence terminates.

%C a(A241218(n)) = n and a(m) <> n for m < A241218(n). - _Reinhard Zumkeller_, Apr 17 2014

%D Higham, Jeff and Tanny, Stephen, A tamely chaotic meta-Fibonacci sequence. Twenty-third Manitoba Conference on Numerical Mathematics and Computing (Winnipeg, MB, 1993). Congr. Numer. 99 (1994), 67-94. [Contains a detailed analysis of this sequence]

%H Reinhard Zumkeller, <a href="/A240808/b240808.txt">Table of n, a(n) for n = 0..20000</a>

%H Rémy Sigrist, <a href="/A240808/a240808.png">Colored scatterplot of a(n) for n = 0..20000</a> (where the color is function of n mod 3)

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

%p a:=proc(n) option remember; global k;

%p if n = 0 then 2

%p elif n = 1 then 1

%p elif n = 2 then 0

%p else

%p if (a(n-1) <= n-1) and (a(n-2) <= n-2) then

%p a(n-1-a(n-1))+a(n-2-a(n-2));

%p else lprint("died with n =",n); return (-1);

%p fi;

%p fi; end;

%p [seq(a(n),n=0..100)];

%t a[n_] := a[n] = Switch[n, 0, 2, 1, 1, 2, 0, _,

%t If[a[n - 1] <= n - 1 && a[n - 2] <= n - 2,

%t a[n - 1 - a[n - 1]] + a[n - 2 - a[n - 2]],

%t Print["died with n =", n]; Return[-1]]];

%t Table[a[n], {n, 0, 100}] (* _Jean-François Alcover_, Oct 02 2024 *)

%o (Haskell)

%o a240808 n = a240808_list !! n

%o a240808_list = 2 : 1 : 0 : zipWith (+) xs (tail xs)

%o where xs = map a240808 $ zipWith (-) [1..] $ tail a240808_list

%o -- _Reinhard Zumkeller_, Apr 17 2014

%Y A006949 and A240807 have the same recurrence but different initial conditions.

%Y Trisections: A244780..A244782.

%K nonn,look

%O 0,1

%A _N. J. A. Sloane_, Apr 15 2014