OFFSET
1,4
COMMENTS
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).
For general integer solutions see A077232 comments.
REFERENCES
T. Nagell, "Introduction to Number Theory", Chelsea Pub., New York, 1964, table p. 301.
O. Perron, "Die Lehre von den Kettenbruechen, Bd.I", Teubner, 1954, 1957 (Sec. 26, p. 91 with explanation on pp. 94,95).
LINKS
Ray Chandler, Table of n, a(n) for n = 1..10000
A. M. Legendre, 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, Essai sur la Théorie des Nombres An VI, Table XII. [Paul Curtz, Apr 10 2019]
FORMULA
EXAMPLE
MATHEMATICA
nmax = 500;
nconv = 200; (* The number of convergents 'nconv' should be increased if the linear recurrence is not found for some terms. *)
nonSquare[n_] := n + Round[Sqrt[n]];
b[n_] := b[n] = Module[{lr}, lr = FindLinearRecurrence[ Numerator[ Convergents[ Sqrt[nonSquare[n]], nconv]]]; (1/2) SelectFirst[lr, #>1&]];
a[n_] := If[n == 1, 1, SelectFirst[{Sqrt[(b[n]^2 - 1)/nonSquare[n]], Sqrt[(b[n]^2 + 1)/nonSquare[n]]}, IntegerQ]];
Table[Print[n, " ", a[n]]; a[n], {n, 1, nmax}] (* Jean-François Alcover, Mar 10 2021 *)
CROSSREFS
KEYWORD
nonn,nice
AUTHOR
Wolfdieter Lang, Nov 08 2002
STATUS
approved