login
a(0)=2, a(1)=0, a(2)=2; 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.
3

%I #17 Oct 02 2024 04:41:47

%S 2,0,2,2,2,2,4,4,4,4,4,6,6,6,8,8,8,8,8,8,10,10,10,12,12,12,12,14,14,

%T 14,16,16,16,16,16,16,16,18,18,18,20,20,20,20,22,22,22,24,24,24,24,24,

%U 26,26,26,28,28,28,28,30,30,30,32,32,32,32,32,32,32,32,34,34,34,36,36,36,36,38,38,38

%N a(0)=2, a(1)=0, a(2)=2; 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.

%D Higham, J.; Tanny, S. More well-behaved meta-Fibonacci sequences. Proceedings of the Twenty-fourth Southeastern International Conference on Combinatorics, Graph Theory, and Computing (Boca Raton, FL, 1993). Congr. Numer. 98(1993), 3-17. See Prop. 2.1.

%H Reinhard Zumkeller, <a href="/A244478/b244478.txt">Table of n, a(n) for n = 0..10000</a>

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

%p f := proc(n) option remember;

%p if n=0 then 2

%p elif n=1 then 0

%p elif n=2 then 2

%p else

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

%p fi;

%p end proc;

%p [seq(f(n),n=0..2000)];

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

%t f[n-1-f[n-1]]+f[n-2-f[n-2]]];

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

%o (Haskell)

%o a244478 n = a244478_list !! n

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

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

%o -- _Reinhard Zumkeller_, Jul 05 2014

%Y A006949, A240807, A240808 use the same recurrence.

%Y See also A244479 (a(n)/2).

%K nonn

%O 0,1

%A _N. J. A. Sloane_, Jul 02 2014