login
a(1)=a(2)=1; if n>2 then a(n) = a(n-2) + (a(n-1) mod 10).
5

%I #31 Sep 08 2022 08:46:15

%S 1,1,2,3,5,8,13,11,14,15,19,24,23,27,30,27,37,34,41,35,46,41,47,48,55,

%T 53,58,61,59,70,59,79,68,87,75,92,77,99,86,105,91,106,97,113,100,113,

%U 103,116,109,125,114,129,123,132,125,137,132,139,141,140,141,141,142,143,145,148,153

%N a(1)=a(2)=1; if n>2 then a(n) = a(n-2) + (a(n-1) mod 10).

%C a(n) - (7/3)*n is periodic with period 60. - _Robert Israel_, Jan 20 2016

%H Robert Israel, <a href="/A267809/b267809.txt">Table of n, a(n) for n = 1..10000</a>

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

%F G.f.: (x + x^2 + x^3 + 2*x^4 + 3*x^5 + 5*x^6 + 7*x^7 + 2*x^8 + 2*x^10 + 2*x^11 + 4*x^12 - 3*x^13 + x^14 + 7*x^15 - 3*x^16 + 4*x^17 + 2*x^18 + 5*x^19 - 3*x^20 - 7*x^21 + x^22 - 6*x^23 + 4*x^24 - x^25 + 3*x^26 + x^27 + 3*x^28 + 4*x^29 - 2*x^30 + 2*x^31 + 2*x^33 + 3*x^34 + 5*x^35 + 7*x^36 + 2*x^37 + 9*x^38 + x^39 - x^40)/(1 - x^2 - x^6 + x^8 + x^12 - x^14 - x^15 + x^17 - x^18 + x^20 + x^21 - x^23 + x^24 - x^26 - x^27 + x^29 + x^33 - x^35 - x^39 + x^41). - _Robert Israel_, Jan 20 2016

%p A[1]:=1: A[2]:= 1:

%p for n from 3 to 100 do A[n]:= A[n-2] + (A[n-1] mod 10) od:

%p seq(A[n],n=1..100); # _Robert Israel_, Jan 20 2016

%t a[1] = a[2] = 1; a[n_] := a[n] = Mod[a[n - 1], 10] + a[n - 2];Array[a,100]

%t nxt[{n_,a_,b_}]:={n+1,b,a+Mod[b,10]}; NestList[nxt,{2,1,1},70] [[All,2]] (* _Harvey P. Dale_, Nov 13 2021 *)

%o (PARI) lista(nn)=print1(a = 1, ", "); print1(b = 1, ", "); for (n=1, nn, c = a + b % 10; print1(c, ", "); a = b; b = c;); \\ _Michel Marcus_, Feb 10 2016

%o (PARI) a=vector(10^5); a[1]=a[2]=1; for(n=3, #a, a[n]=a[n-1]%10+a[n-2]); a \\ _Altug Alkan_, Mar 20 2018

%o (Magma) I:=[1,1,2]; [n le 3 select I[n] else Self(n-2)+(Self(n-1)mod 10): n in [1..70]]; // _Vincenzo Librandi_, Feb 12 2016

%o (GAP) a:=[1,1];; for n in [3..70] do a[n]:=a[n-2]+(a[n-1] mod 10); od; a; # _Muniru A Asiru_, Mar 20 2018

%Y Cf. A000045, A267806, A267807, A267808.

%K nonn,easy

%O 1,3

%A _José María Grau Ribas_, Jan 20 2016