A031405 Numbers k such that the continued fraction for sqrt(k) has even period 2*m and the m-th term of the periodic part is 2.
6, 12, 14, 20, 21, 28, 30, 33, 42, 44, 45, 52, 55, 56, 60, 70, 72, 77, 90, 95, 110, 112, 117, 126, 132, 133, 138, 153, 154, 156, 161, 165, 180, 182, 184, 189, 190, 207, 209, 210, 221, 234, 240, 248, 253, 261, 272, 275, 276, 285, 286, 297, 299, 306, 310, 315
Offset: 1
Keywords
Examples
The c.f. for sqrt(6) is [2; 2, 4, ...] with period 2 and 1st term of the periodic part 2. The c.f. for sqrt(14) is [3; 1, 2, 1, 6, ...] with period 4 and 2nd term of the periodic part 2. The c.f. for sqrt(21) is [4; 1, 1, 2, 1, 1, 8, ...] with period 6 and 3rd term of the periodic part 2.
Links
- T. D. Noe, Table of n, a(n) for n = 1..1000
Programs
-
Maple
filter:= proc(n) local P,l; if issqr(n) then return false fi; P:= numtheory:-cfrac(sqrt(n),'periodic','quotients')[2]; l:= nops(P); if l::odd then false else P[l/2] = 2 fi end proc: select(filter, [$1..1000]); # Robert Israel, Apr 14 2016
-
Mathematica
n = 1; t = {}; While[Length[t] < 50, n++; If[! IntegerQ[Sqrt[n]], c = ContinuedFraction[Sqrt[n]]; len = Length[c[[2]]]; If[EvenQ[len] && c[[2, len/2]] == 2, AppendTo[t, n]]]]; t