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.
-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
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.
Links
- Robert Israel, Table of n, a(n) for n = 0..10000
- Georg Fischer, Table of the continued fractions of sqrt(0..20000)
- Oskar Perron, Die Lehre von den Kettenbrüchen, B. G. Teubner (1913), section 24, p. 87 ff.
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 *)
Comments