OFFSET
1,3
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
LINKS
Harvey P. Dale, Table of n, a(n) for n = 1..1000
Index entries for linear recurrences with constant coefficients, signature (0,1,1,-1,-1,1,1,-1,-1,1,1,0,-1).
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
EXAMPLE
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.
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 *)
PROG
(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
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Amarnath Murthy, Jun 18 2004
EXTENSIONS
Edited, corrected and extended by Klaus Brockhaus, Jun 19 2004
STATUS
approved