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.

A096062 a(1) = a(2) = 1; for n > 2, if a(n-2) + a(n-1) > n then a(n) = abs(a(n-2) - a(n-1)) else a(n) = a(n-2) + a(n-1).

Original entry on oeis.org

1, 1, 2, 3, 5, 2, 7, 5, 2, 7, 9, 2, 11, 13, 2, 15, 17, 2, 19, 17, 2, 19, 21, 2, 23, 25, 2, 27, 29, 2, 31, 29, 2, 31, 33, 2, 35, 37, 2, 39, 41, 2, 43, 41, 2, 43, 45, 2, 47, 49, 2, 51, 53, 2, 55, 53, 2, 55, 57, 2, 59, 61, 2, 63, 65, 2, 67, 65, 2, 67, 69, 2, 71, 73, 2, 75, 77, 2, 79, 77, 2
Offset: 1

Views

Author

Amarnath Murthy, Jun 18 2004

Keywords

Comments

For n > 1: a(n) = 2 if n mod 12 = {0,3,6,9}, a(n) = n if n mod 12 = {5,7}, a(n) = n-1 if n mod 12 = {2,4}, a(n) = n-2 if n mod 12 = {1,11}, a(n) = n-3 if n mod 12 = {8,10}. - Klaus Brockhaus, Jun 19 2004

Examples

			a(8) + a(9) = 5 + 2 = 7 < 10, so a(10) = 7.
a(16) + a(17) = 15 + 17 = 32 > 18, so a(18) = abs(15 - 17) = 2.
		

Programs

  • Mathematica
    nxt[{n_,a_,b_}]:={n+1,b,If[a+b>n+1,Abs[a-b],a+b]}; Transpose[ NestList[ nxt,{2,1,1},90]][[2]] (* Harvey P. Dale, Sep 22 2014 *)
  • PARI
    m=81;print1(a=1,",",b=1,",");for(n=3,m,print1(c=if(a+b>n,abs(a-b),a+b),",");a=b;b=c)
    
  • PARI
    Vec(x*(2*x^13 -2*x^12 +x^11 +5*x^10 -x^9 -x^8 +x^7 +x^6 -x^5 +3*x^4 +x^3 +x^2 +x +1) / ((x -1)^2*(x +1)*(x^2 -x +1)*(x^2 +x +1)^2*(x^4 -x^2 +1)) + O(x^100)) \\ Colin Barker, Mar 12 2015

Formula

G.f.: x*(2*x^13 -2*x^12 +x^11 +5*x^10 -x^9 -x^8 +x^7 +x^6 -x^5 +3*x^4 +x^3 +x^2 +x +1) / ((x -1)^2*(x +1)*(x^2 -x +1)*(x^2 +x +1)^2*(x^4 -x^2 +1)). - Colin Barker, Mar 12 2015

Extensions

Edited, corrected and extended by Klaus Brockhaus, Jun 19 2004