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.

Showing 1-5 of 5 results.

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

Original entry on oeis.org

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
Offset: 1

Views

Author

Keywords

Comments

Any string of five consecutive terms m^2 - 2 through m^2 + 2 for m > 2 in the sequence has the corresponding periods 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 + (-1)^m * x^(2m)], or equivalently, the denominators satisfy the linear recurrence b(n+2m) = C*b(n+m) - (-1)^m * b(n), where a(n) is equal to 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 (A002522 except the initial term 1). 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 A020349-A020439. - Ralf Stephan, Dec 12 2013
From William Krier, Dec 12 2024: (Start)
a(m^2-4) = 4 for even m>=6 since sqrt(m^2-4) = [m-1; 1, (m-4)/2, 1, 2*(m-1)].
a(m^2-4) = 6 for odd m>=5 since sqrt(m^2-4) = [m-1; 1, (m-3)/2, 2, (m-3)/2, 1, 2*(m-1)].
a(m^2+4) = 2 for even m>=2 since sqrt(m^2+4) = [m; m/2, 2*m].
a(m^2+4) = 5 for odd m>=3 since sqrt(m^2+4) = [m; (m-1)/2, 1, 1, (m-1)/2, 2*m]. (End)

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).

Crossrefs

Programs

  • 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[ # ]]]&
    pcf[n_]:=Module[{s=Sqrt[n]},If[IntegerQ[s],0,Length[ContinuedFraction[s][[2]]]]]; Array[pcf,110] (* Harvey P. Dale, Jul 15 2017 *)
  • 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,(n-P[k+1]^2)/Q[k]);k++;for(i=1,k-1,if(P[i]==P[k]&&Q[i]==Q[k],return(k-i)));x=(P[k]+s)/Q[k];f=floor(x)) \\ Charles R Greathouse IV, Jul 31 2011
    
  • PARI
    isok(n, p) = {localprec(p); my(cf = contfrac(sqrt(n))); setsearch(Set(cf), 2*cf[1]);}
    a(n) = {if (issquare(n), 0, my(p=100); while (! isok(n, p), p+=100); localprec(p); my(cf = contfrac(sqrt(n))); for (k=2, #cf, if (cf[k] == 2*cf[1], return (k-1))););} \\ Michel Marcus, Jul 07 2021
    
  • Python
    from sympy.ntheory.continued_fraction import continued_fraction_periodic
    def a(n):
        cfp = continued_fraction_periodic(0, 1, d=n)
        return 0 if len(cfp) == 1 else len(cfp[1])
    print([a(n) for n in range(1, 104)]) # Michael S. Branicky, Aug 22 2021

A013943 Period of continued fraction for sqrt(m), m = n-th nonsquare.

Original entry on oeis.org

1, 2, 1, 2, 4, 2, 1, 2, 2, 5, 4, 2, 1, 2, 6, 2, 6, 6, 4, 2, 1, 2, 4, 5, 2, 8, 4, 4, 4, 2, 1, 2, 2, 2, 3, 2, 10, 8, 6, 12, 4, 2, 1, 2, 6, 5, 6, 4, 2, 6, 7, 6, 4, 11, 4, 2, 1, 2, 10, 2, 8, 6, 8, 2, 7, 5, 4, 12, 6, 4, 4, 2, 1, 2, 2, 5, 10, 2, 6, 5, 2, 8, 8, 10, 16, 4, 4, 11, 4, 2, 1, 2, 12, 2, 2, 9, 6, 8, 15, 2, 6, 6
Offset: 1

Views

Author

Keywords

Crossrefs

Programs

  • Mathematica
    nonSquares = Select[Range[120], !IntegerQ[Sqrt[#]]&]; a[n_] := Length[ Last[ ContinuedFraction[ Sqrt[ nonSquares[[n]] ]]]]; Table[a[n], {n, 1, Length[nonSquares]}] (* Jean-François Alcover, May 27 2013 *)
  • Python
    from math import isqrt
    from sympy.ntheory.continued_fraction import continued_fraction_periodic
    def A013943(n): return len(continued_fraction_periodic(0,1,n+(k:=isqrt(n))+int(n>=k*(k+1)+1))[-1]) # Chai Wah Wu, Jul 20 2024

A107356 Period of continued fraction for (1 + square root of n-th squarefree integer)/2.

Original entry on oeis.org

2, 2, 1, 4, 4, 2, 2, 1, 4, 2, 3, 6, 2, 6, 4, 2, 1, 2, 8, 4, 4, 2, 3, 6, 6, 5, 4, 10, 8, 4, 2, 1, 4, 6, 6, 6, 3, 4, 3, 6, 10, 4, 6, 8, 9, 6, 2, 4, 4, 2, 2, 1, 6, 2, 7, 8, 2, 12, 4, 9, 3, 6, 12, 6, 18, 6, 7, 4, 6, 7, 6, 6, 14, 4, 2, 2, 12, 10, 6, 6, 4, 10, 7, 4, 18, 4, 4, 2, 3, 6, 5, 20, 14, 8, 5, 12, 6, 10
Offset: 1

Views

Author

Steven Finch, May 24 2005

Keywords

Examples

			a(7) = 2 because 11 is the 7th smallest squarefree integer and (1 + sqrt 11)/2 = [2,6,3,6,3,6,3,... ] thus has an eventual period of 2. We omit 1 from the list of squarefree integers.
		

Crossrefs

Programs

  • Mathematica
    (* first do *) Needs["NumberTheory`NumberTheoryFunctions`"] (* then *) s = Drop[ Select[ Range[162], SquareFreeQ[ # ] &], 1]; Length[ ContinuedFraction[ # ][[2]]] & /@ ((1 + Sqrt[s])/2) (* Robert G. Wilson v, May 27 2005 *)
    Length[ContinuedFraction[(Sqrt[#]+1)/2][[2]]]&/@Select[Range[ 2,200], SquareFreeQ] (* Harvey P. Dale, Aug 16 2021 *)

Formula

a(n) = A146326(A005117(n+1)). - R. J. Mathar, Sep 24 2009

Extensions

More terms from Robert G. Wilson v, May 27 2005

A387203 Number of additively indecomposable elements in the real quadratic field Q(sqrt(D)) up to multiplication by totally positive units, where D = A005117(n) is the n-th squarefree number.

Original entry on oeis.org

2, 1, 1, 2, 2, 6, 3, 3, 2, 1, 5, 7, 1, 6, 2, 10, 5, 2, 8, 4, 2, 1, 7, 6, 4, 11, 2, 13, 8, 2, 7, 7, 4, 7, 20, 9, 11, 2, 9, 8, 19, 2, 6, 6, 21, 20, 1, 2, 2, 18, 9, 9, 16, 3, 21, 12, 3, 12, 2, 27, 11, 10, 18, 3, 34, 13, 17, 2, 8, 23, 12, 5, 18, 2, 22, 11, 24, 15, 26, 15, 6, 22, 27, 2, 31, 4, 2
Offset: 2

Views

Author

Robin Visser, Aug 21 2025

Keywords

Comments

For any totally real field K, an additively indecomposable element of K is a totally positive element in the maximal order of K which cannot be written as the sum of two totally positive integral elements of K. Here, an element x of K is totally positive if all conjugates of x are positive real numbers.
Let K = Q(sqrt(D)) be a real quadratic field. By studying the continued fraction expansion of sqrt(D), Dress and Scharlau classified all additively indecomposable elements of K and showed that every such indecomposable element has its norm bounded by the discriminant of K.

Examples

			For n = 2, every additively indecomposable element in Q(sqrt(A005117(2))) = Q(sqrt(2)) is of the form u or u*(2 + sqrt(2)), for some totally positive unit u. Thus a(2) = 2.
For n = 3, every additively indecomposable element in Q(sqrt(A005117(3))) = Q(sqrt(3)) is a totally positive unit, so a(3) = 1.
For n = 4, every additively indecomposable element in Q(sqrt(A005117(4))) = Q(sqrt(5)) is a totally positive unit, so a(4) = 1.
For n = 5, every additively indecomposable element in Q(sqrt(A005117(5))) = Q(sqrt(6)) is of the form u or u*(3 + sqrt(6)), for some totally positive unit u. Thus a(5) = 2.
		

Crossrefs

Programs

A387207 The maximal norm of an additively indecomposable element in the real quadratic field Q(sqrt(D)), where D = A005117(n) is the n-th squarefree number.

Original entry on oeis.org

2, 1, 1, 3, 2, 10, 5, 3, 2, 1, 4, 9, 1, 11, 2, 26, 7, 6, 10, 4, 2, 1, 9, 19, 13, 10, 7, 21, 9, 2, 25, 13, 9, 7, 58, 29, 15, 2, 16, 33, 33, 3, 14, 10, 18, 74, 1, 3, 2, 82, 41, 21, 43, 13, 22, 30, 7, 18, 5, 24, 25, 51, 34, 4, 106, 53, 27, 11, 37, 28, 57, 9, 59, 2, 122, 61, 42, 16, 130, 65, 11
Offset: 2

Views

Author

Robin Visser, Aug 21 2025

Keywords

Comments

For any totally real field K, an additively indecomposable element of K is a totally positive element in the maximal order of K which cannot be written as the sum of two totally positive integral elements of K. Here, an element x of K is totally positive if all conjugates of x are positive real numbers.
Let K = Q(sqrt(D)) be a real quadratic field. By studying the continued fraction expansion of sqrt(D), Dress and Scharlau classified all additively indecomposable elements of K and showed that every such indecomposable element has its norm bounded by the discriminant of K.

Examples

			For n = 2, every additively indecomposable element in Q(sqrt(A005117(2))) = Q(sqrt(2)) has norm either 1 or 2, thus a(2) = 2.
For n = 3, every additively indecomposable element in Q(sqrt(A005117(3))) = Q(sqrt(3)) has norm 1, thus a(3) = 1.
For n = 4, every additively indecomposable element in Q(sqrt(A005117(4))) = Q(sqrt(5)) has norm 1, thus a(4) = 1.
For n = 5, every additively indecomposable element in Q(sqrt(A005117(5))) = Q(sqrt(6)) has norm either 1 or 3, thus a(5) = 3.
		

Crossrefs

Programs

Formula

a(n) <= A005117(n) for all n >= 2 [Dress-Scharlau].
Showing 1-5 of 5 results.