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.

A240808 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.

This page as a plain text file.
%I A240808 #25 Oct 02 2024 06:47:46
%S A240808 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 A240808 10,12,17,13,12,20,16,12,20,19,15,20,19,18,23,19,21,26,19,21,26,19,24,
%U A240808 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 A240808 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 A240808 a(A241218(n)) = n and a(m) <> n for m < A241218(n). - _Reinhard Zumkeller_, Apr 17 2014
%D A240808 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 A240808 Reinhard Zumkeller, <a href="/A240808/b240808.txt">Table of n, a(n) for n = 0..20000</a>
%H A240808 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 A240808 <a href="/index/Ho#Hofstadter">Index entries for Hofstadter-type sequences</a>
%p A240808 a:=proc(n) option remember; global k;
%p A240808 if n = 0 then 2
%p A240808 elif n = 1 then 1
%p A240808 elif n = 2 then 0
%p A240808 else
%p A240808 if (a(n-1) <= n-1) and (a(n-2) <= n-2) then
%p A240808 a(n-1-a(n-1))+a(n-2-a(n-2));
%p A240808 else lprint("died with n =",n); return (-1);
%p A240808 fi;
%p A240808 fi; end;
%p A240808 [seq(a(n),n=0..100)];
%t A240808 a[n_] := a[n] = Switch[n, 0, 2, 1, 1, 2, 0, _,
%t A240808    If[a[n - 1] <= n - 1 && a[n - 2] <= n - 2,
%t A240808    a[n - 1 - a[n - 1]] + a[n - 2 - a[n - 2]],
%t A240808    Print["died with n =", n]; Return[-1]]];
%t A240808 Table[a[n], {n, 0, 100}] (* _Jean-François Alcover_, Oct 02 2024 *)
%o A240808 (Haskell)
%o A240808 a240808 n = a240808_list !! n
%o A240808 a240808_list = 2 : 1 : 0 : zipWith (+) xs (tail xs)
%o A240808    where xs = map a240808 $ zipWith (-) [1..] $ tail a240808_list
%o A240808 -- _Reinhard Zumkeller_, Apr 17 2014
%Y A240808 A006949 and A240807 have the same recurrence but different initial conditions.
%Y A240808 Trisections: A244780..A244782.
%K A240808 nonn,look
%O A240808 0,1
%A A240808 _N. J. A. Sloane_, Apr 15 2014