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.

A240807 a(0)=a(1)=-1, 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.

This page as a plain text file.
%I A240807 #19 Oct 02 2024 04:42:14
%S A240807 -1,-1,2,1,1,3,3,3,2,4,6,4,4,5,4,8,9,6,7,8,8,8,9,10,10,9,13,14,10,12,
%T A240807 13,12,14,15,14,15,16,16,16,17,18,18,19,20,20,20,19,23,24,20,22,22,22,
%U A240807 25,23,22,27,27,25,28,27,27,29,29,29,29,31,31,31,32,32,32,33,34,34,35,36,36,36,37,38,38,39,40,40,40,40,39,43,44,40,42,42,42
%N A240807 a(0)=a(1)=-1, 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 A240807 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.
%H A240807 N. J. A. Sloane, <a href="/A240807/b240807.txt">Table of n, a(n) for n = 0..20000</a>
%H A240807 <a href="/index/Ho#Hofstadter">Index entries for Hofstadter-type sequences</a>
%p A240807 a:=proc(n) option remember;
%p A240807 if n = 0 then  -1
%p A240807 elif n = 1 then -1
%p A240807 elif n = 2 then 2
%p A240807 else
%p A240807     if (a(n-1) <= n-1) and (a(n-2) <= n-2) then
%p A240807     a(n-1-a(n-1))+a(n-2-a(n-2));
%p A240807     else lprint("died with n =",n); return (-1);
%p A240807     fi;
%p A240807 fi; end;
%p A240807 [seq(a(n),n=0..100)];
%t A240807 a[n_] := a[n] = Switch[n, 0, -1, 1, -1, 2, 2, _,
%t A240807    If[a[n-1] <= n-1 && a[n-2] <= n-2,
%t A240807    a[n-1-a[n-1]] + a[n-2-a[n-2]],
%t A240807    Print["died with n =", n]; Return[-1]]];
%t A240807 Table[a[n], {n, 0, 100}] (* _Jean-François Alcover_, Oct 02 2024 *)
%o A240807 (Haskell)
%o A240807 a240807 n = a240807_list !! n
%o A240807 a240807_list = -1 : -1 : 2 : zipWith (+) xs (tail xs)
%o A240807    where xs = map a240807 $ zipWith (-) [1..] $ tail a240807_list
%o A240807 -- _Reinhard Zumkeller_, Apr 17 2014
%Y A240807 A006949 and A240808 have the same recurrence but different initial conditions.
%K A240807 sign
%O A240807 0,3
%A A240807 _N. J. A. Sloane_, Apr 15 2014