login
a(n) is the smallest positive integer m such that n appears as the denominator of a semiconvergent to sqrt(m).
2

%I #12 Oct 24 2020 13:59:50

%S 1,2,2,3,2,8,2,7,5,11,3,2,5,7,3,11,2,13,10,6,5,11,8,23,10,3,14,12,2,

%T 31,7,32,13,23,8,20,10,5,15,40,2,22,10,23,39,27,15,7,6,51,26,41,19,71,

%U 5,3,17,14,24,11,26,41,15,8,17,54,21,72,6,2,13,5,17,96

%N a(n) is the smallest positive integer m such that n appears as the denominator of a semiconvergent to sqrt(m).

%C a(n) <= A338307(n).

%o (PARI) { A338319(n) = my(a, b, r, q, v); if(n==1, return(1)); for(m=1, oo, if(issquare(m), next); r=sqrtint(m); a=0; b=1; q=[1, 0]~; while(q[2]<n, v=(r+a)\b; a=b*v-a; b=(m-a^2)/b; q=[0, 1; 1, v]*q; ); if(Mod(q[2],q[1])==n, return(m)); ); }

%Y Cf. A338307, A338320.

%K nonn

%O 1,2

%A _Max Alekseyev_, Oct 22 2020