login
a(0)=1, a(1)=1; for n>1, a(n)=a(n-1)+a(n-2) if a(n-1) is less than or equal to n-1, otherwise a(n)=a(n-1)-(n-1).
1

%I #23 Apr 30 2020 04:03:44

%S 1,1,2,3,5,1,6,7,13,5,18,8,26,14,1,15,16,31,14,45,26,6,32,10,42,18,60,

%T 34,7,41,12,53,22,75,42,8,50,14,64,26,90,50,9,59,16,75,30,105,58,10,

%U 68,18,86,34,120,66,11,77,20,97,38,135,74,12,86,22,108,42,150,82,13,95,24,119,46,165,90,14,104,26

%N a(0)=1, a(1)=1; for n>1, a(n)=a(n-1)+a(n-2) if a(n-1) is less than or equal to n-1, otherwise a(n)=a(n-1)-(n-1).

%C The graph of the sequence appears random until n>16, after which the graph creates seven distinct lines.

%H Colin Barker, <a href="/A322558/b322558.txt">Table of n, a(n) for n = 0..1000</a>

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

%F For n>16, the sequence follows a pattern of seven, and each term lies on one of the following lines:

%F If n is of the form 7k+3, then a(n) = (11/7)n+(30/7);

%F if n is of the form 7k+4, then a(n) = (4/7)n+(26/7);

%F if n is of the form 7k+5, then a(n) = (15/7)n+(30/7);

%F if n is of the form 7k+6, then a(n) = (8/7)n+(22/7);

%F if n is of the form 7k, then a(n) = (1/7)n+3;

%F if n is of the form 7k+1, then a(n) = (9/7)n+(26/7);

%F if n is of the form 7k+2, then a(n) = (2/7)n+(24/7).

%F From _Colin Barker_, Aug 29 2019: (Start)

%F G.f.: (1 + x + 2*x^2 + 3*x^3 + 5*x^4 + x^5 + 6*x^6 + 5*x^7 + 11*x^8 + x^9 + 12*x^10 - 2*x^11 + 24*x^12 + 2*x^13 - 12*x^14 - 10*x^15 + 8*x^16 - 2*x^17 + 3*x^18 - 6*x^19 + 4*x^20 + 11*x^21 + 15*x^22 - 17*x^23 - 2*x^24 - 2*x^25 - 4*x^26 - 4*x^27 - 4*x^28 - 8*x^29 + 8*x^30) / ((1 - x)^2*(1 + x + x^2 + x^3 + x^4 + x^5 + x^6)^2).

%F a(n) = 2*a(n-7) - a(n-14) for n>30.

%F (End)

%t a[0] = a[1] = 1; a[n_] := a[n] = If[a[n - 1] <= n - 1, a[n - 1] + a[n - 2], a[n - 1] - n + 1]; Array[a, 100, 0] (* _Amiram Eldar_, Aug 29 2019 *)

%o (PARI) Vec((1 + x + 2*x^2 + 3*x^3 + 5*x^4 + x^5 + 6*x^6 + 5*x^7 + 11*x^8 + x^9 + 12*x^10 - 2*x^11 + 24*x^12 + 2*x^13 - 12*x^14 - 10*x^15 + 8*x^16 - 2*x^17 + 3*x^18 - 6*x^19 + 4*x^20 + 11*x^21 + 15*x^22 - 17*x^23 - 2*x^24 - 2*x^25 - 4*x^26 - 4*x^27 - 4*x^28 - 8*x^29 + 8*x^30) / ((1 - x)^2*(1 + x + x^2 + x^3 + x^4 + x^5 + x^6)^2) + O(x^40)) \\ _Colin Barker_, Aug 29 2019

%Y Cf. A133058.

%K nonn,easy

%O 0,3

%A _Jackson Haselhorst_, Aug 28 2019