login

Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.

a(1)=1, a(2)=4, a(n) = (n*a(n-1) - (n-1)*a(n-2)) mod (n+1).
0

%I #36 Oct 15 2023 16:05:24

%S 1,4,2,1,3,6,0,3,7,10,4,3,5,1,9,10,8,12,4,20,10,7,13,1,25,4,18,19,17,

%T 21,13,29,31,27,35,19,13,25,1,8,36,23,5,41,15,20,10,30,40,20,8,32,38,

%U 26,50,2,40,23,57,50,2,35,33,37,29,45,13,8,18,69,39,26

%N a(1)=1, a(2)=4, a(n) = (n*a(n-1) - (n-1)*a(n-2)) mod (n+1).

%C Goes as high as 2917 before settling to a final value of 77 for all n >= 2982.

%H <a href="/index/Con#constant">Index entries for eventually constant sequences</a>

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

%F a(n) = 77 for n >= 2982.

%t a[1] = 1; a[2] = 4; a[n_] := a[n] = Mod[n*a[n - 1] - (n - 1)*a[n - 2], n + 1]; Array[a, 100] (* _Amiram Eldar_, Aug 10 2021 *)

%t nxt[{n_,a_,b_}]:={n+1,b,Mod[b(n+1)-n*a,n+2]}; NestList[nxt,{2,1,4},80][[;;,2]] (* _Harvey P. Dale_, Oct 15 2023 *)

%o (PARI) lista(nn) = {my(va = vector(nn)); va[1] = 1; va[2] = 4; for (n=3, nn, va[n] = (n*va[n-1] - (n-1)*va[n-2]) % (n+1);); va;} \\ _Michel Marcus_, Aug 10 2021

%K nonn,easy

%O 1,2

%A _Steven M. Altschuld_, Aug 09 2021