OFFSET
0,1
COMMENTS
If the continued fraction for sqrt(N) has period (2k + 1) and k-th convergent P(k)/Q(k) [taking P(-1)=1; Q(-1)=0 where necessary], then the i-th positive solution V(i) = [x(i),y(i)] to the Pell equation x^2 - N*y^2 = 1 satisfies the recurrence V(i+2) = 2*A*V(i+1) - V(i) starting with V(0)=(1,0); V(1) = (A,B) where A = 2*S^2 + 1; B = 2*S*T and S = P(k)*Q(k) + P(k-1)*Q(k-1); T = Q(k)^2 + Q(k-1)^2.
LINKS
Michael De Vlieger, Table of n, a(n) for n = 0..1000 (Terms 0..999 from T. D. Noe)
Dario Alpern, Continued Fraction calculator.
Keith Matthews, Calculating the simple continued fraction of a quadratic irrational.
Ulrich Sondermann, Continued Fractions.
EXAMPLE
For n = 2, 2n+1 = 5. a(2) = 13 and we indeed have sqrt(13) = [3; 1, 1, 1, 1, 6] with period 5, the first one in the sequence sqrt(29) = [5; 2, 1, 1, 2, 10], sqrt(53) = [7; 3, 1, 1, 3, 14], sqrt(74) = [8; 1, 1, 1, 1, 16], sqrt(85) = [9; 4, 1, 1, 4, 18], sqrt(89) = [9; 2, 3, 3, 2, 18], ...
MATHEMATICA
nn = 50; t = Table[0, {nn}]; n = 1; found = 0; While[found < nn, n++; If[! IntegerQ[Sqrt[n]], c = ContinuedFraction[Sqrt[n]]; len = Length[c[[2]]]; If[OddQ[len] && (len + 1)/2 <= nn && t[[(len + 1)/2]] == 0, t[[(len + 1)/2]] = n; found++]]]; t (* T. D. Noe, Apr 04 2014 *)
CROSSREFS
KEYWORD
nonn
AUTHOR
Lekraj Beedassy, Jul 17 2001
EXTENSIONS
More terms from Naohiro Nomoto, Jan 01 2002
STATUS
approved