login
a(n) is the smallest number of the form k*a(n-1)+a(n-2) for k>0 that is relatively prime to n, with a(0) = 0 and a(1) = 1.
0

%I #7 Jun 04 2023 19:14:26

%S 0,1,1,2,3,8,11,19,49,68,117,185,487,672,1159,1831,4821,6652,11473,

%T 18125,47723,65848,113571,179419,472409,651828,1124237,1776065,

%U 4676367,6452432,11128799,17581231,46291261,63872492,110163753,284199998,394363751,678563749,1751491249

%N a(n) is the smallest number of the form k*a(n-1)+a(n-2) for k>0 that is relatively prime to n, with a(0) = 0 and a(1) = 1.

%t nxt[{n_,a_,b_}]:=Module[{k=1},While[!CoprimeQ[k*b+a,n+1],k++];{n+1,b,k*b+a}]; NestList[nxt,{1,0,1},40][[;;,2]] (* _Harvey P. Dale_, Jun 04 2023 *)

%o (PARI) ar(n)=local(r,m);r=vector(n);r[1]=0;r[2]=1;for(k=2,n-1,m=1;while(gcd(m*r[k]+r[k-1],k)>1,m++);r[k+1]=m*r[k]+r[k-1]);r

%K nonn

%O 0,4

%A _Franklin T. Adams-Watters_, Feb 05 2012