login
a(1) = a(2) = a(3) = 1, a(4) = 3; a(n) = n - a(n-a(n-1)) - a(n-a(n-2)) for n > 4.
2

%I #15 Aug 20 2017 13:03:14

%S 1,1,1,3,1,4,2,1,6,1,9,2,1,11,1,14,2,1,16,1,19,2,1,21,1,24,2,1,26,1,

%T 29,2,1,31,1,34,2,1,36,1,39,2,1,41,1,44,2,1,46,1,49,2,1,51,1,54,2,1,

%U 56,1,59,2,1,61,1,64,2,1,66,1,69,2,1,71,1,74,2,1,76,1,79,2,1,81,1,84,2,1,86,1,89,2,1,91,1,94,2,1,96,1,99,2,1,101

%N a(1) = a(2) = a(3) = 1, a(4) = 3; a(n) = n - a(n-a(n-1)) - a(n-a(n-2)) for n > 4.

%H Colin Barker, <a href="/A289205/b289205.txt">Table of n, a(n) for n = 1..1000</a>

%H <a href="/index/Rec#order_10">Index entries for linear recurrences with constant coefficients</a>, signature (0,0,0,0,2,0,0,0,0,-1).

%F a(5k) = a(5k + 3) = 1, a(5k + 1) = 5k - 1, a(5k + 2) = 2, a(5k + 4) = 5k + 1 for k > 0.

%F From _Colin Barker_, Jun 28 2017: (Start)

%F G.f.: x*(1 + x)*(1 + x^2 + 2*x^3 - x^4 + 3*x^5 - 3*x^6 + 2*x^7 - 2*x^8 + x^9 + x^10 - 2*x^11 + 2*x^12) / ((1 - x)^2*(1 + x + x^2 + x^3 + x^4)^2).

%F a(n) = 2*a(n-5) - a(n-10) for n>12.

%F (End)

%t LinearRecurrence[{0,0,0,0,2,0,0,0,0,-1},{1,1,1,3,1,4,2,1,6,1,9,2,1,11},120] (* _Harvey P. Dale_, Aug 20 2017 *)

%o (PARI) q=vector(10^5); q[1]=q[2]=q[3]=1;q[4]=3; for(n=5, #q, q[n] = n-q[n-q[n-1]]-q[n-q[n-2]]); q

%o (PARI) Vec(x*(1 + x)*(1 + x^2 + 2*x^3 - x^4 + 3*x^5 - 3*x^6 + 2*x^7 - 2*x^8 + x^9 + x^10 - 2*x^11 + 2*x^12) / ((1 - x)^2*(1 + x + x^2 + x^3 + x^4)^2) + O(x^100)) \\ _Colin Barker_, Jun 28 2017

%Y Cf. A244477.

%K nonn,easy

%O 1,4

%A _Altug Alkan_, Jun 28 2017