

A003285


Period of continued fraction for square root of n (or 0 if n is a square).
(Formerly M0018)


32



0, 1, 2, 0, 1, 2, 4, 2, 0, 1, 2, 2, 5, 4, 2, 0, 1, 2, 6, 2, 6, 6, 4, 2, 0, 1, 2, 4, 5, 2, 8, 4, 4, 4, 2, 0, 1, 2, 2, 2, 3, 2, 10, 8, 6, 12, 4, 2, 0, 1, 2, 6, 5, 6, 4, 2, 6, 7, 6, 4, 11, 4, 2, 0, 1, 2, 10, 2, 8, 6, 8, 2, 7, 5, 4, 12, 6, 4, 4, 2, 0, 1, 2, 2, 5, 10, 2, 6, 5, 2, 8, 8, 10, 16, 4, 4, 11, 4, 2, 0, 1, 2, 12
(list;
graph;
refs;
listen;
history;
text;
internal format)



OFFSET

1,3


COMMENTS

Any string of five consecutive terms m^2  2 through m^2 + 2 for m>2 in the sequence has the corresponding period lengths 4,2,0,1,2.  Lekraj Beedassy, Jul 17 2001
For m>1, a(m^2+m) = 2 and the continued fraction is m,2,2*m,2,2*m,2,2*m,...  Arran Fernandez, Aug 14 2011
Apparently the generating function of the sequence for the denominators of continued fraction convergents to sqrt(n) is always rational and of form p(x)/[1  C*x^m + x^(2m)], or equivalently, the denominators satisfy the linear recurrence b(n+2m) = C*b(n+m)  b(n). If so, then it seems that a(n) is half the value of m for each nonsquare n, or 0. See A006702 for the conjecture regarding C. The same conjectures apply to the sequences of the numerators of continued fraction convergents to sqrt(n).  Ralf Stephan, Dec 12 2013
If a(n)=1, n is of form k^2+1 (A069987). See A013642 for a(n)=2, A013643 for a(n)=3, A013644 for a(n)=4, A010337 for a(n)=5, A020347 for a(n)=6, A010338 for a(n)=7, A020348 for a(n)=8, A010339 for a(n)=9, and furthermore A020349A020439.  Ralf Stephan, Dec 12 2013


REFERENCES

A. Brousseau, Number Theory Tables. Fibonacci Association, San Jose, CA, 1973, p. 197.
N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).


LINKS

T. D. Noe and Ray Chandler, Table of n, a(n) for n = 1..10000 (first 5000 terms from T. D. Noe)
M. Beceanu, Period of the Continued Fraction of sqrt(n)
Leon Bernstein, Fundamental units and cycles in the period of real quadratic number fields, I. Pacific J. Math 63 (1976): 3761.
Ron Knott, All squareroot continued fractions eventually repeat
R. Mestrovic, Euclid's theorem on the infinitude of primes: a historical survey of its proofs (300 BC2012) and another new proof, arXiv preprint arXiv:1202.3670, 2012  From N. J. A. Sloane, Jun 13 2012
Justin T. Miller, Families of Continued Fractions
C. D. Patterson and H. C. Williams, Some Periodic Continued Fractions with Long Periods, Mathematics of Computation, Vol. 44 (1985), No. 170, pp. 523532.
A. J. van der Poorten, An introduction to continued fractions
A. J. van der Poorten, Fractional parts of the period of the ...
A. M. Rockett and P. Szuesz, On the lengths of the periods of the continued fractions of squareroots of integers, Forum Mathematicum, 2 (1990), 119123.
R. G. Stanton, C. Sudler, Jr. and H. C. Williams, An Upper Bound for the Period of the Simple Continued Fraction for Sqrt(D), Pacific Journal of Math., Vol. 67 (1976), No. 2, pp. 525536.
Hanna UsckaWehlou, Continued Fractions and Digital Lines with Irrational Slopes, in Discrete Geometry for Computer Imagery, Lecture Notes in Computer Science, Volume 4992/2008, SpringerVerlag.
H. C. Williams, A Numerical Investigation Into the Length of the Period of the Continued Fraction Expansion of Sqrt(D), Mathematics of Computation, Vol. 36 (1981), No. 154, pp. 593601.


MAPLE

f:= n > if issqr(n) then 0
else nops(numtheory:cfrac(sqrt(n), 'periodic', 'quotients')[2]) fi:
map(f, [$1..100]); # Robert Israel, Sep 02 2015


MATHEMATICA

a[n_] := ContinuedFraction[Sqrt[n]] // If[Length[ # ] == 1, 0, Length[Last[ # ]]]&


PROG

(PARI) a(n)=if(issquare(n), return(0)); my(s=sqrt(n), x=s, f=floor(s), P=[0], Q=[1], k); while(1, k=#P; P=concat(P, f*Q[k]P[k]); Q=concat(Q, (nP[k+1]^2)/Q[k]); k++; for(i=1, k1, if(P[i]==P[k]&&Q[i]==Q[k], return(ki))); x=(P[k]+s)/Q[k]; f=floor(x)) \\ Charles R Greathouse IV, Jul 31 2011


CROSSREFS

Cf. A035015, A013943, A054269, A061490, A065938, A067280, A097853.
Sequence in context: A227318 A166692 A046766 * A059347 A071496 A071502
Adjacent sequences: A003282 A003283 A003284 * A003286 A003287 A003288


KEYWORD

nonn,nice


AUTHOR

N. J. A. Sloane.


STATUS

approved



