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.

A244477 a(1)=3, a(2)=2, a(3)=1; thereafter a(n) = a(n-a(n-1)) + a(n-a(n-2)).

Original entry on oeis.org

3, 2, 1, 3, 5, 4, 3, 8, 7, 3, 11, 10, 3, 14, 13, 3, 17, 16, 3, 20, 19, 3, 23, 22, 3, 26, 25, 3, 29, 28, 3, 32, 31, 3, 35, 34, 3, 38, 37, 3, 41, 40, 3, 44, 43, 3, 47, 46, 3, 50, 49, 3, 53, 52, 3, 56, 55, 3, 59, 58, 3, 62, 61, 3, 65, 64, 3, 68, 67, 3, 71, 70, 3, 74, 73, 3, 77, 76, 3, 80
Offset: 1

Views

Author

N. J. A. Sloane, Jul 02 2014

Keywords

Comments

Similar to Hofstadter's Q-sequence A005185 but with different starting values.
Golomb describes this as "quasi-periodic sequence with a quasi-period of 3".

References

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

Crossrefs

Cf. A005185.
Cf. A010872.

Programs

  • Haskell
    a244477 n = a244477_list !! (n-1)
    a244477_list = 3 : 2 : 1 : zipWith (+)
       (map a244477 $ zipWith (-) [4..] $ tail a244477_list)
       (map a244477 $ zipWith (-) [4..] $ drop 2 a244477_list)
    -- Reinhard Zumkeller, Jul 05 2014
    
  • Magma
    [n le 3 select 4-n else Self(n-Self(n-1)) + Self(n-Self(n-2)): n in [1..80]]; // Vincenzo Librandi, Nov 24 2015
  • Maple
    f := proc(n) option remember;
        if n<=3 then
            4-n
        elif n > procname(n-1) and n > procname(n-2) then
            RETURN(procname(n-procname(n-1))+procname(n-procname(n-2)));
        else
            ERROR(" died at n= ", n);
        fi;
    end proc;
    [seq(f(n),n=0..200)];
  • Mathematica
    a[1] = 3; a[2] = 2; a[3] = 1; a[n_] := a[n] = a[n - a[n - 1]] + a[n - a[n - 2]]; Array[a, 75] (* or *)
    Flatten@ Table[{Mod[3n, 3] +3, 3n -1, 3n -2}, {n, 25}] (* Robert G. Wilson v, Nov 23 2015 *)

Formula

From Colin Barker, Nov 23 2015: (Start)
a(n) = 2*a(n-3) - a(n-6) for n>6.
G.f.: x*(2*x^5 + x^4 - 3*x^3 + x^2 + 2*x + 3)/((x - 1)^2*(x^2 + x + 1)^2). (End)
a(3*k) = 3*k-2, a(3*k+1) = 3, a(3*k+2) = 3*k+2. - Nathan Fox, Apr 02 2017
a(n) = 3*(m-1)^2*floor(n/3) - (3*m^2-8*m+2), where m = n mod 3. - Luce ETIENNE, Oct 17 2018