%I #22 Mar 10 2021 08:24:51
%S 1,1,1,2,3,1,1,3,2,5,4,1,1,4,39,2,12,42,5,1,1,5,24,13,2,273,3,4,6,1,1,
%T 6,4,3,5,2,531,30,24,3588,7,1,1,7,90,25,66,12,2,20,13,69,4,3805,8,1,1,
%U 8,5967,4,936,30,413,2,125,5,3,6630,40,6,9,1,1,9,6,41,1122,3,21,53,2,165,120,1260,221064,4,5,569,10,1,1,10,22419
%N a(n) is smallest natural number satisfying Pell equation b^2- d(n)*a^2= +1 or = -1, with d(n)=A000037(n) (nonsquare). Corresponding smallest b(n)=A077232(n).
%C If d(n)=A000037(n) is from A003654 (that is if the regular continued fraction for sqrt(d(n)) has odd (primitive) period length) then the -1 option applies. For such d(n) the minimal b(n) and a(n) numbers for the +1 option are 2*b(n)^2 + 1 and 2*b(n)*a(n), respectively (see Perron I, pp. 94,p5).
%C For general integer solutions see A077232 comments.
%C If the trivial solution x=1, y=0 is included, the sequence becomes A006703. - _T. D. Noe_, May 17 2007
%D T. Nagell, "Introduction to Number Theory", Chelsea Pub., New York, 1964, table p. 301.
%D O. Perron, "Die Lehre von den Kettenbruechen, Bd.I", Teubner, 1954, 1957 (Sec. 26, p. 91 with explanation on pp. 94,95).
%H Ray Chandler, <a href="/A077233/b077233.txt">Table of n, a(n) for n = 1..10000</a>
%H A. M. Legendre, <a href="https://books.google.fr/books?id=EBtPMqDlPxcC&pg=PA517">Fractions les plus simples m/n qui satisfont à l'équation m^2 - an^2 =+-1 pour tout nombre non quarré a depuis 2 jusqu'à 1003</a>, Essai sur la Théorie des Nombres An VI, Table XII. [_Paul Curtz_, Apr 10 2019]
%F a(n)=sqrt((A077232(n)^2 - (-1)^(c(n)))/A000037(n)) with c(n)=1 if A000037(n)=A003654(k) for some k>=1 else c(n)=0.
%e d=10=A000037(7)=A003654(3), therefore a(7)=1 and b(7)=A077232(7)=3 give 3^2=10*1^2 -1 and 2*b(7)^2+1=19 and 2*b(7)*a(7)=2*3*1=6 satisfy 19^2 - 10*6^2 = +1.
%e d=11=A000037(8) is not in A003654, therefore there is no (nontrivial) solution of the b^2 - d*a^2 = -1 Pell equation and a(8)=3 and b(8)=A077232(8)=10 satisfy 10^2 - 11*3^2 = +1. See A077232 for further examples.
%t nmax = 500;
%t nconv = 200; (* The number of convergents 'nconv' should be increased if the linear recurrence is not found for some terms. *)
%t nonSquare[n_] := n + Round[Sqrt[n]];
%t b[n_] := b[n] = Module[{lr}, lr = FindLinearRecurrence[ Numerator[ Convergents[ Sqrt[nonSquare[n]], nconv]]]; (1/2) SelectFirst[lr, #>1&]];
%t a[n_] := If[n == 1, 1, SelectFirst[{Sqrt[(b[n]^2 - 1)/nonSquare[n]], Sqrt[(b[n]^2 + 1)/nonSquare[n]]}, IntegerQ]];
%t Table[Print[n, " ", a[n]]; a[n], {n, 1, nmax}] (* _Jean-François Alcover_, Mar 10 2021 *)
%Y Cf. A000037, A003654, A003814, A033317, A077232.
%K nonn,nice
%O 1,4
%A _Wolfdieter Lang_, Nov 08 2002