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.

A308780 First element of the periodic part of the continued fraction expansion of sqrt(k), where the period is 2.

This page as a plain text file.
%I A308780 #16 May 04 2024 14:57:49
%S A308780 1,2,1,3,2,1,4,2,1,5,2,1,6,4,3,2,1,7,2,1,8,4,2,1,9,6,3,2,1,10,5,4,2,1,
%T A308780 11,2,1,12,8,6,4,3,2,1,13,2,1,14,7,4,2,1,15,10,6,5,3,2,1,16,8,4,2,1,
%U A308780 17,2,1,18,12,9,6,4,3,2,1,19,2,1
%N A308780 First element of the periodic part of the continued fraction expansion of sqrt(k), where the period is 2.
%H A308780 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>.
%e A308780 The continued fractions for sqrt(3..8) are:
%e A308780    3 1;1,2
%e A308780    4 2 (square)
%e A308780    5 2;4
%e A308780    6 2;2,4
%e A308780    7 2;1,1,1,4
%e A308780    8 2;1,4
%e A308780 Those for 3, 6 and 8 have a period of 2, therefore the sequence starts with 1, 2, 1.
%p A308780 s := proc(n) if not issqr(n) then numtheory[cfrac](sqrt(n), 'periodic', 'quotients')[2]; if nops(%) = 2 then return %[1] fi fi; NULL end:
%p A308780 seq(s(n), n=1..399); # _Peter Luschny_, Jul 01 2019
%t A308780 Reap[For[k = 3, k <= 399, k++, If[!IntegerQ[Sqrt[k]], cf = ContinuedFraction[Sqrt[k]]; If[Length[cf[[2]]] == 2, Sow[cf[[2, 1]]]]]]][[2, 1]] (* _Jean-François Alcover_, May 03 2024 *)
%t A308780 (* Second program (much simpler): *)
%t A308780 Table[2 a/b, {a, 1, 20}, {b, Rest@Divisors[2 a]}] // Flatten (* _Jean-François Alcover_, May 04 2024, after a remark by _Kevin Ryde_ *)
%Y A308780 Cf. A013642, A308778.
%K A308780 nonn
%O A308780 1,2
%A A308780 _Georg Fischer_, Jun 24 2019