cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A267857 Length of the period of the continued fraction for the square root of D, the discriminant of indefinite binary quadratic forms. D is given in A079896.

This page as a plain text file.
%I A267857 #23 Jun 07 2025 08:15:01
%S A267857 1,2,2,5,1,2,6,2,4,5,4,4,1,2,3,8,6,2,6,5,2,6,4,11,1,2,8,2,7,12,6,2,2,
%T A267857 5,6,5,8,10,4,11,1,2,2,8,15,6,9,10,6,2,16,5,4,10,2,16,4,9,4,4,1,2,9,2,
%U A267857 8,2,17,8,10,6,6,2,16,5,4,8,4,21
%N A267857 Length of the period of the continued fraction for the square root of D, the discriminant of indefinite binary quadratic forms. D is given in A079896.
%C A267857 This is a subsequence of A003285.
%C A267857 If a(n) is even then the smallest positive integer solution of the Pell equation x^2 - D(n)*y^2 = +1 with D(n) = A079896(n) is given by (x0, y0) = (P,Q) with P/Q = [a,b[1], ..., b[a(n)-1]]. If a(n) is odd then the smallest positive integer solution of the Pell equation x^2 - D(n)*y^2 = +1 is given by (x0, y0) = (P^2 + D(n)*Q^2, 2*P*Q). See e.g., the Silverman reference Theorem 40.4 on p. 351.
%C A267857 For positive integer d, d not a square, the Pell equations X^2 - d*Y^2 = +4 and X^2 - d*Y^2 = -4 have no proper solutions. For D(n) = A079896(n) there are solutions for X^2 - D(n)*Y^2 = +4 or -4 (inclusive or). See the Wolfdieter Lang link under A225953 for Pell +4 or -4 solutions.
%D A267857 J. H. Silverman, A Friendly Introduction to Number Theory, 3rd ed., Pearson Education, Inc, 2006, p. 351.
%H A267857 Robin Visser, <a href="/A267857/b267857.txt">Table of n, a(n) for n = 1..10000</a>
%e A267857 a(1)  = 1  because sqrt(5)  = [2,repeat(4)].
%e A267857 a(2)  = 2  because sqrt(8)  = [2,repeat(1,4)].
%e A267857 a(24) = 11 because sqrt(61) = [7,repeat(1,4,3,1,2,2,1,3,4,1,14)].
%e A267857 Pell +1 equation: n = 24 with D = 61 has odd a(24)
%e A267857   P/Q = [7,1,4,3,1,2,2,1,3,4,1] = 29718/3805 (in lowest terms). Therefore (x0, y0) = (1766319049, 226153980), see A174762 (Of course, (1, 0) is the smallest nonnegative solution.)
%p A267857 See the _Robert Israel_ program under A003285, adapted to n -> a(n).
%t A267857 Length[Last@ #] & /@ ContinuedFraction@ Sqrt@ Select[Range@ 200, And[MemberQ[{0, 1}, Mod[#, 4]], ! IntegerQ@ Sqrt@ #] &] (* _Michael De Vlieger_, Feb 11 2016, after A079896 *)
%o A267857 (SageMath)
%o A267857 def a(n):
%o A267857     i, D = 1, Integer(5)
%o A267857     while(i < n):
%o A267857         D += 1; i += 1*(((D%4) in [0, 1]) and (not D.is_square()))
%o A267857     K.<a> = QuadraticField(D)
%o A267857     return continued_fraction(a).period_length()  # _Robin Visser_, Jun 06 2025
%Y A267857 Cf. A003285, A033313, A033317, A079896, A225953.
%K A267857 nonn,easy
%O A267857 1,2
%A A267857 _Wolfdieter Lang_, Feb 03 2016
%E A267857 Offset corrected by _Robin Visser_, Jun 06 2025