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.

A308778 Central element(s) in the period of the continued fraction expansion of sqrt(n), or 0 if no such element exists, or -1 if n is a square.

Original entry on oeis.org

-1, -1, 0, 1, -1, 0, 2, 1, 1, -1, 0, 3, 2, 1, 2, 1, -1, 0, 4, 3, 2, 2, 4, 3, 1, -1, 0, 5, 2, 1, 2, 5, 1, 2, 4, 1, -1, 0, 6, 4, 3, 2, 2, 5, 2, 2, 6, 5, 1, -1, 0, 7, 2, 1, 6, 2, 2, 4, 1, 7, 2, 2, 6, 1, -1, 0, 8, 7, 4, 4, 2, 7, 2, 5, 1, 1, 4, 2, 4, 7, 1, -1, 0
Offset: 0

Views

Author

Georg Fischer, Jun 24 2019

Keywords

Comments

The continued fraction expansion of sqrt(n) is periodic (where n is no square), and the period splits in two halves which are mirrored around the center. With r = floor(sqrt(n)) the expansion takes one of the forms:
[r; i, j, k, ..., m, m, ..., k, j, i, 2*r] (odd period length) or
[r; i, j, k, ..., m, ..., k, j, i, 2*r] (even period length)
[r; 2*r] (empty symmetric part, for n = r^2 + 1)
This sequence lists the central element(s) m, or 0 for n = r^2 + 1, or -1 for n = r^2.
a(k^2-1) = 1 for k >= 2. - Robert Israel, Nov 04 2019

Examples

			CF(sqrt(2906)) = [53;1,9,1,3,1,3,1,1,14,1,5,2,2,5,1,14,1,1,3,1,3,1,9,1,106], odd period, two central elements, a(2906) = 2.
		

Crossrefs

Programs

  • Maple
    f:= proc(n) local L,m;
      if issqr(n) then return -1
      elif issqr(n-1) then return 0
      fi;
      L:= numtheory:-cfrac(sqrt(n),periodic,quotients);
      m:= nops(L[2]);
      L[2][floor(m/2)]
    end proc:
    map(f, [$0..100]); # Robert Israel, Nov 04 2019
  • Mathematica
    Array[Which[IntegerQ@ Sqrt@ #, -1, IntegerQ@ Sqrt[# - 1], 0, True, #[[Floor[Length[#]/2]]] &@ Last@ ContinuedFraction@ Sqrt@ #] &, 83, 0] (* Michael De Vlieger, Jul 07 2019 *)

A031599 Numbers k such that the continued fraction for sqrt(k) has odd period and if the last term of the periodic part is deleted the two central terms are both 11.

Original entry on oeis.org

809, 2581, 2785, 2890, 4217, 5353, 6949, 7114, 7621, 9698, 9893, 10289, 11177, 11597, 12461, 15325, 15817, 17429, 18218, 18754, 19298, 19946, 20506, 20789, 21361, 22234, 23833, 25693, 27085, 27737, 29065, 29741, 30202, 30425, 30545, 30890, 31237, 32290
Offset: 1

Views

Author

Keywords

Programs

  • Mathematica
    cf11Q[n_]:=Module[{s=Sqrt[n],len,cf},cf=If[IntegerQ[s],{2,2}, ContinuedFraction[ s][[2]]];len=Length[cf];OddQ[len]&&cf[[(len+1)/2]] == 11]; Select[Range[32000],cf11Q] (* Harvey P. Dale, Mar 18 2018 *)

Extensions

Corrected and extended by Harvey P. Dale, Mar 18 2018
Definitions of A031599-A031688 clarified by N. J. A. Sloane, Aug 17 2021
Showing 1-2 of 2 results.