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-2 of 2 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

A091449 Array T(n,k) read by antidiagonals, where row n is the increasing sequence of numbers m for which the simple continued fraction of sqrt(m) has period n, n >= 0, k >= 1.

Original entry on oeis.org

1, 2, 4, 3, 5, 9, 41, 6, 10, 16, 7, 130, 8, 17, 25, 13, 14, 269, 11, 26, 36, 19, 29, 23, 370, 12, 37, 49, 58, 21, 53, 28, 458, 15, 50, 64, 31, 73, 22, 74, 32, 697, 18, 65, 81, 106, 44, 202, 45, 85, 33, 986, 20, 82, 100, 43, 113, 69, 250, 52, 89, 34, 1313, 24, 101, 121
Offset: 0

Views

Author

Clark Kimberling, Feb 03 2004

Keywords

Comments

A permutation of the positive integers.

Examples

			Array begins:
  n\k|   1   2   3   4   5   6   7    8    9   10   11
  ---+------------------------------------------------
   0 |   1   4   9  16  25  36  49   64   81  100  121
   1 |   2   5  10  17  26  37  50   65   82  101  122
   2 |   3   6   8  11  12  15  18   20   24   27   30
   3 |  41 130 269 370 458 697 986 1313 1325 1613 1714
   4 |   7  14  23  28  32  33  34   47   55   60   62
   5 |  13  29  53  74  85  89 125  173  185  218  229
   6 |  19  21  22  45  52  54  57   59   70   77   88
   7 |  58  73 202 250 274 314 349  425  538  761 1010
   8 |  31  44  69  71  91  92 108  135  153  158  160
   9 | 106 113 137 149 265 389 493  610  698  754  970
  10 |  43  67  86  93 115 116 118  129  154  159  161
The least n for which CF(sqrt(n)) has period of length 4 is n=7, with CF=[2;1,1,1,4,1,1,1,4,1,1,1,4,...]; thus T(4,1)=7.
[The array T(n,k) is indexed by n=0,1,2,3,..., k=1,2,3... .]
Row 0 consists of squares: 1,4,9,...
		

Crossrefs

Rows 0-100 are: A000290 (except the initial 0), A002522 (except the initial 1), A013642, A013643, A013644, A010337, A020347, A010338, A020348, A010339, A020349-A020439.

Extensions

a(17) = T(3,3) corrected by Pontus von Brömssen, Nov 23 2024
Showing 1-2 of 2 results.