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.

A254308 a(n) = a(n-1) + (if a(n-1) is odd a(n-2) else a(n-3)) with a(0) = 0, a(1) = 1.

Original entry on oeis.org

0, 1, 1, 2, 3, 5, 8, 11, 19, 30, 41, 71, 112, 153, 265, 418, 571, 989, 1560, 2131, 3691, 5822, 7953, 13775, 21728, 29681, 51409, 81090, 110771, 191861, 302632, 413403, 716035, 1129438, 1542841, 2672279, 4215120, 5757961, 9973081, 15731042, 21489003, 37220045
Offset: 0

Views

Author

Russell Walsmith, Feb 23 2015

Keywords

Comments

Every third iteration is a tribonacci-type recursion: a(n) = a(n-1) + a(n-3) otherwise it is Fibonacci-type a(n) = a(n-1) + a(n-2).

Examples

			For n = 7, a(n-1) is even so 8 + 3 = 11.
G.f. = x + x^2 + 2*x^3 + 3*x^4 + 5*x^5 + 8*x^6 + 11*x^7 + 19*x^8 + 30*x^9 + ...
		

Crossrefs

Programs

  • Haskell
    a254308 n = a254308_list !! n
    a254308_list = 0 : 1 : 1 : zipWith3 (\u v w -> u + if odd u then v else w)
                   (drop 2 a254308_list) (tail a254308_list) a254308_list
    -- Reinhard Zumkeller, Feb 24 2015
    
  • Magma
    m:=60; R:=PowerSeriesRing(Integers(), m); [0] cat Coefficients(R!(x*(1+x+2*x^2-x^3+x^4)/(1-4*x^3+x^6))); // G. C. Greubel, Aug 03 2018
  • Mathematica
    CoefficientList[Series[x*(1+x+2*x^2-x^3+x^4)/(1-4*x^3+x^6), {x, 0, 60}], x] (* G. C. Greubel, Aug 03 2018 *)
    nxt[{a_,b_,c_}]:={b,c,If[OddQ[c],c+b,c+a]}; NestList[nxt,{0,1,1},50][[All,1]] (* or *) LinearRecurrence[{0,0,4,0,0,-1},{0,1,1,2,3,5},50] (* Harvey P. Dale, May 12 2022 *)
  • PARI
    {a(n) = polcoeff( x * if( n<0, n=-n; -(1 - x + 2*x^2 + x^3 + x^4), (1 + x + 2*x^2 - x^3 + x^4)) / (1 - 4*x^3 + x^6) + x * O(x^n), n)}; /* Michael Somos, Feb 23 2015 */
    

Formula

Two identities: a(3n)/2 + a(3n-3)/2 = a(3n-1); a(3n)/2 - a(3n-3)/2 = a(3n-2).
G.f.: x * (1 + x + 2*x^2 - x^3 + x^4) / (1 - 4*x^3 + x^6). - Michael Somos, Feb 23 2015
0 = a(n) - 4*a(n+3) + a(n+6) for all n in Z. - Michael Somos, Feb 23 2015
a(3*n) = A052530(n). a(3*n-2) = A001835(n). a(3*n+2) = A001834(n). - Michael Somos, Feb 23 2015