login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
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. 2

%I #18 Nov 05 2019 00:57:30

%S -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,

%T 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,

%U -1,0,8,7,4,4,2,7,2,5,1,1,4,2,4,7,1,-1,0

%N 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.

%C 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:

%C [r; i, j, k, ..., m, m, ..., k, j, i, 2*r] (odd period length) or

%C [r; i, j, k, ..., m, ..., k, j, i, 2*r] (even period length)

%C [r; 2*r] (empty symmetric part, for n = r^2 + 1)

%C This sequence lists the central element(s) m, or 0 for n = r^2 + 1, or -1 for n = r^2.

%C a(k^2-1) = 1 for k >= 2. - _Robert Israel_, Nov 04 2019

%H Robert Israel, <a href="/A308778/b308778.txt">Table of n, a(n) for n = 0..10000</a>

%H Georg Fischer, <a href="https://github.com/gfis/fasces/blob/master/oeis/cfsqrt/sqrt20k.txt">Table of the continued fractions of sqrt(0..20000)</a>

%H Oskar Perron, <a href="https://archive.org/details/dielehrevondenk00perrgoog/page/n5">Die Lehre von den Kettenbrüchen</a>, B. G. Teubner (1913), section 24, p. 87 ff.

%e 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.

%p f:= proc(n) local L,m;

%p if issqr(n) then return -1

%p elif issqr(n-1) then return 0

%p fi;

%p L:= numtheory:-cfrac(sqrt(n),periodic,quotients);

%p m:= nops(L[2]);

%p L[2][floor(m/2)]

%p end proc:

%p map(f, [$0..100]); # _Robert Israel_, Nov 04 2019

%t Array[Which[IntegerQ@ Sqrt@ #, -1, IntegerQ@ Sqrt[# - 1], 0, True, #[[Floor[Length[#]/2]]] &@ Last@ ContinuedFraction@ Sqrt@ #] &, 83, 0] (* _Michael De Vlieger_, Jul 07 2019 *)

%Y Cf. A031509-A031688.

%K sign,look

%O 0,7

%A _Georg Fischer_, Jun 24 2019

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 24 13:16 EDT 2024. Contains 371951 sequences. (Running on oeis4.)