A296388 a(1) = a(3) = 1, a(2) = a(4) = 3, a(5) = 4; a(n) = n - a(n-a(n-1)) - a(n-a(n-4)) for n > 5.
1, 3, 1, 3, 4, 2, 1, 3, 3, 6, 1, 8, 3, 10, 1, 12, 3, 14, 1, 16, 3, 18, 1, 20, 3, 22, 1, 24, 3, 26, 1, 28, 3, 30, 1, 32, 3, 34, 1, 36, 3, 38, 1, 40, 3, 42, 1, 44, 3, 46, 1, 48, 3, 50, 1, 52, 3, 54, 1, 56, 3, 58, 1, 60, 3, 62, 1, 64, 3, 66, 1, 68, 3, 70, 1, 72, 3, 74, 1, 76, 3, 78, 1, 80, 3, 82, 1, 84, 3, 86
Offset: 1
Links
- Colin Barker, Table of n, a(n) for n = 1..1000
- Index entries for linear recurrences with constant coefficients, signature (0,1,0,1,0,-1).
Programs
-
Mathematica
Fold[Append[#1, #2 - #1[[#2 - #1[[#2 - 1]] ]] - #1[[#2 - #1[[#2 - 4]] ]] ] &, {1, 3, 1, 3, 4}, Range[6, 90]] (* Michael De Vlieger, Dec 11 2017 *)
-
PARI
q=vector(10^5); q[1]=1;q[2]=3;q[3]=1;q[4]=3;q[5]=4;for(n=6, #q, q[n] = n-q[n-q[n-1]]-q[n-q[n-4]]); q
-
PARI
Vec(x*(1 + 3*x + 2*x^4 - 4*x^5 - 3*x^6 + x^7 - x^8 + 4*x^9 + x^10 + x^11 - x^13) / ((1 - x)^2*(1 + x)^2*(1 + x^2)) + O(x^100)) \\ Colin Barker, Dec 12 2017
Formula
a(2*k) = 2*(k-2) for k >= 5, a(4*j+1) = 3 for j >= 2, a(4*m-1) = 1 for m >= 1.
From Colin Barker, Dec 12 2017: (Start)
G.f.: x*(1 + 3*x + 2*x^4 - 4*x^5 - 3*x^6 + x^7 - x^8 + 4*x^9 + x^10 + x^11 - x^13) / ((1 - x)^2*(1 + x)^2*(1 + x^2)).
a(n) = a(n-2) + a(n-4) - a(n-6) for n>12.
(End)