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.

Original entry on oeis.org

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, 10, 12, 17, 13, 12, 20, 16, 12, 20, 19, 15, 20, 19, 18, 23, 19, 21, 26, 19, 21, 26, 19, 24, 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
Offset: 0

Views

Author

N. J. A. Sloane, Apr 15 2014

Keywords

Comments

a(A241218(n)) = n and a(m) <> n for m < A241218(n). - Reinhard Zumkeller, Apr 17 2014

References

  • 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]

Crossrefs

A006949 and A240807 have the same recurrence but different initial conditions.
Trisections: A244780..A244782.

Programs

  • Haskell
    a240808 n = a240808_list !! n
    a240808_list = 2 : 1 : 0 : zipWith (+) xs (tail xs)
       where xs = map a240808 $ zipWith (-) [1..] $ tail a240808_list
    -- Reinhard Zumkeller, Apr 17 2014
  • Maple
    a:=proc(n) option remember; global k;
    if n = 0 then 2
    elif n = 1 then 1
    elif n = 2 then 0
    else
    if (a(n-1) <= n-1) and (a(n-2) <= n-2) then
    a(n-1-a(n-1))+a(n-2-a(n-2));
    else lprint("died with n =",n); return (-1);
    fi;
    fi; end;
    [seq(a(n),n=0..100)];
  • Mathematica
    a[n_] := a[n] = Switch[n, 0, 2, 1, 1, 2, 0, _,
       If[a[n - 1] <= n - 1 && a[n - 2] <= n - 2,
       a[n - 1 - a[n - 1]] + a[n - 2 - a[n - 2]],
       Print["died with n =", n]; Return[-1]]];
    Table[a[n], {n, 0, 100}] (* Jean-François Alcover, Oct 02 2024 *)