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.

A003814 Numbers k such that the continued fraction for sqrt(k) has odd period length.

This page as a plain text file.
%I A003814 #68 Jan 05 2025 19:51:33
%S A003814 2,5,10,13,17,26,29,37,41,50,53,58,61,65,73,74,82,85,89,97,101,106,
%T A003814 109,113,122,125,130,137,145,149,157,170,173,181,185,193,197,202,218,
%U A003814 226,229,233,241,250,257,265,269,274,277,281,290,293,298,313,314,317
%N A003814 Numbers k such that the continued fraction for sqrt(k) has odd period length.
%C A003814 All primes of the form 4m + 1 are here. - _T. D. Noe_, Mar 19 2012
%C A003814 These numbers have no prime factors of the form 4m + 3. - _Thomas Ordowski_, Jul 01 2013
%C A003814 This sequence is a proper subsequence of the so-called 1-happy number products A007969. See the W. Lang link there, eq. (1), with B = 1, C = a(n), also with a table at the end. This is due to the soluble Pell equation R^2 - C*S^2 = -1 for C = a(n). See e.g., Perron, Satz 3.18. on p. 93, and the table on p. 91 with the numbers D of the first column that do not have a number in brackets in the second column (Teilnenner von sqrt(D)). - _Wolfdieter Lang_, Sep 19 2015
%D A003814 W. Paulsen, Calkin-Wilf sequences for irrational numbers, Fib. Q., 61:1 (2023), 51-59.
%D A003814 O. Perron, Die Lehre von den Kettenbrüchen, Band I, Teubner Verlagsgesellschaft, Stuttgart, 1954.
%D A003814 Kenneth H. Rosen, Elementary Number Theory and Its Applications, Addison-Wesley, 1984, page 426 (but beware of errors!).
%H A003814 Ray Chandler, <a href="/A003814/b003814.txt">Table of n, a(n) for n = 1..10000</a> (first 1000 terms from T. D. Noe)
%H A003814 S. R. Finch, <a href="/A000924/a000924.pdf">Class number theory</a> [Cached copy, with permission of the author]
%H A003814 P. J. Rippon and H. Taylor, <a href="https://web.archive.org/web/2024*/https://www.fq.math.ca/Papers1/42-2/quartrippon02_2004.pdf">Even and odd periods in continued fractions of square roots</a>, Fibonacci Quarterly 42, May 2004, pp. 170-180.
%p A003814 isA003814 := proc(n)
%p A003814     local cf,p ;
%p A003814     if issqr(n) then
%p A003814         return false;
%p A003814     end if;
%p A003814     for p in numtheory[factorset](n) do
%p A003814         if modp(p,4) = 3 then
%p A003814             return false;
%p A003814         end if;
%p A003814     end do:
%p A003814     cf := numtheory[cfrac](sqrt(n),'periodic','quotients') ;
%p A003814     type( nops(op(2,cf)),'odd') ;
%p A003814 end proc:
%p A003814 A003814 := proc(n)
%p A003814     option remember;
%p A003814     if n = 1 then
%p A003814         2;
%p A003814     else
%p A003814         for a from procname(n-1)+1 do
%p A003814             if isA003814(a) then
%p A003814                 return a;
%p A003814             end if;
%p A003814         end do:
%p A003814     end if;
%p A003814 end proc:
%p A003814 seq(A003814(n),n=1..40) ; # _R. J. Mathar_, Oct 19 2014
%t A003814 Select[Range[100], ! IntegerQ[Sqrt[#]] && OddQ[Length[ContinuedFraction[Sqrt[#]][[2]]]] &] (* _T. D. Noe_, Mar 19 2012 *)
%o A003814 (PARI)
%o A003814 cyc(cf) = {
%o A003814   if(#cf==1, return([])); \\ There is no cycle
%o A003814   my(s=[]);
%o A003814   for(k=2, #cf,
%o A003814     s=concat(s, cf[k]);
%o A003814     if(cf[k]==2*cf[1], return(s)) \\ Cycle found
%o A003814   );
%o A003814   0 \\ Cycle not found
%o A003814 }
%o A003814 select(n->#cyc(contfrac(sqrt(n)))%2==1, vector(400, n, n)) \\ _Colin Barker_, Oct 19 2014
%Y A003814 Cf. A010333, A003654, A007969.
%Y A003814 Cf. A031396.
%Y A003814 Cf. A206586 (period has positive even length).
%K A003814 nonn
%O A003814 1,1
%A A003814 _N. J. A. Sloane_, Walter Gilbert