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.
%I A308778 #18 Nov 05 2019 00:57:30 %S A308778 -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 A308778 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 A308778 -1,0,8,7,4,4,2,7,2,5,1,1,4,2,4,7,1,-1,0 %N 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. %C A308778 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 A308778 [r; i, j, k, ..., m, m, ..., k, j, i, 2*r] (odd period length) or %C A308778 [r; i, j, k, ..., m, ..., k, j, i, 2*r] (even period length) %C A308778 [r; 2*r] (empty symmetric part, for n = r^2 + 1) %C A308778 This sequence lists the central element(s) m, or 0 for n = r^2 + 1, or -1 for n = r^2. %C A308778 a(k^2-1) = 1 for k >= 2. - _Robert Israel_, Nov 04 2019 %H A308778 Robert Israel, <a href="/A308778/b308778.txt">Table of n, a(n) for n = 0..10000</a> %H A308778 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 A308778 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 A308778 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 A308778 f:= proc(n) local L,m; %p A308778 if issqr(n) then return -1 %p A308778 elif issqr(n-1) then return 0 %p A308778 fi; %p A308778 L:= numtheory:-cfrac(sqrt(n),periodic,quotients); %p A308778 m:= nops(L[2]); %p A308778 L[2][floor(m/2)] %p A308778 end proc: %p A308778 map(f, [$0..100]); # _Robert Israel_, Nov 04 2019 %t A308778 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 A308778 Cf. A031509-A031688. %K A308778 sign,look %O A308778 0,7 %A A308778 _Georg Fischer_, Jun 24 2019