OFFSET
2,1
COMMENTS
The i-th solution pair V(i) = [x(i), y(i)] to the Pellian x^2 - D*y^2 = 1 for a given least solution x(1) = n may be generated through the recurrence V(i+2) = 2*n*V(i+1) - V(i) taking V(0) = [1, 0] and V(1) = [n, sqrt((n^2-1)/a(n))]. V(i) stands for the numerator and denominator of the 2i-th convergent of the continued fraction expansion of sqrt(D).
Thus setting n = 3, for instance, we have D = a(3) = 2 and V(1) = [3, 2] so that along with V(0) = [1, 0] recurrence V(i+2) = 6*V(i+1) - V(i) generates [A001333(2k), A000129(2k)]. Similarly, setting n = 9 generates [A023039, A060645], respectively the numerator and denominator of the 2i-th convergent of sqrt(a(9)), i.e., sqrt(5). - Lekraj Beedassy, Feb 26 2002
LINKS
Ray Chandler, Table of n, a(n) for n = 2..1001
Eric Weisstein's World of Mathematics, Pell Equation.
MATHEMATICA
squarefreepart[n_] :=
Times @@ Power @@@ ({#[[1]], Mod[#[[2]], 2]} & /@ FactorInteger[n]);
pellminx[d_] := Module[{q, p, z}, {q, p} = ContinuedFraction[Sqrt[d]];
If[OddQ[p // Length], p = Join[p, p]];
z = FromContinuedFraction[Join[{q}, Drop[p, -1]]]; Numerator[z]]
NMAX = 60; a = {};
For[n = 2, n <= NMAX, n++, s = squarefreepart[n^2 - 1];
sd = s Divisors[Sqrt[(n^2 - 1)/s]]^2;
t = Sort[Transpose[{sd, pellminx[#] & /@ sd}]];
AppendTo[a, Select[t, #[[2]] == n &, 1][[1, 1]]]
]; a (* Herbert Kociemba, Jun 05 2022 *)
CROSSREFS
KEYWORD
nonn
AUTHOR
STATUS
approved