OFFSET
1,3
COMMENTS
A well-defined solution sequence for recurrence a(n) = a(n-a(n-2)) + a(n-a(n-3)).
LINKS
Colin Barker, Table of n, a(n) for n = 1..1000
Index entries for linear recurrences with constant coefficients, signature (1,-1,1,1,-1,1,-1).
FORMULA
For k > 2:
a(4*k) = 4*k+1,
a(4*k+1) = 4*k-2,
a(4*k+2) = 4,
a(4*k+3) = 3.
From Colin Barker, Aug 04 2019: (Start)
G.f.: x*(1 + 3*x^2 + 2*x^3 - 2*x^4 + 4*x^5 - 7*x^6 + 6*x^7 - 3*x^8) / ((1 - x)^2*(1 + x)*(1 + x^2)^2).
a(n) = a(n-1) - a(n-2) + a(n-3) + a(n-4) - a(n-5) + a(n-6) - a(n-7) for n > 9.
(End)
MATHEMATICA
a[n_] := a[n] = If[n < 6, {1, 1, 3, 5, 2}[[n]], a[n - a[n-2]] + a[n - a[n-3]]]; Array[a, 87] (* Giovanni Resta, Aug 07 2019 *)
PROG
(PARI) q=vector(100); q[1]=1; q[2]=1; q[3]=3; q[4]=5; q[5]=2; for(n=6, #q, q[n]=q[n-q[n-2]]+q[n-q[n-3]]); q
(PARI) Vec(x*(1 + 3*x^2 + 2*x^3 - 2*x^4 + 4*x^5 - 7*x^6 + 6*x^7 - 3*x^8) / ((1 - x)^2*(1 + x)*(1 + x^2)^2) + O(x^40)) \\ Colin Barker, Aug 15 2019
(Magma) I:=[1, 1, 3, 5, 2]; [n le 5 select I[n] else Self(n-Self(n-2))+Self(n-Self(n-3)): n in [1..90]]; // Marius A. Burtea, Aug 07 2019
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Altug Alkan, Aug 04 2019
STATUS
approved