OFFSET
1,1
COMMENTS
Any periodic continued fraction represents a rational number, in particular [b(0);[c,c,...,c,b(p)]]. An integer requires b(p)=2*b(0). The exclusion of p < 3 makes sense because there should be at least two constant c-terms. Note that, with m=a0, the terms associated with the continued fractions [m;[2m]] (p=1) and [m;[c,2m]] (p=2) are those in A320773.
General aspect: If [m;[c,c,...,c,2m]] is an integer, it belongs to a quadratic subsequence, see link "Special periodic continued fractions".
The four sequences below, see formula, cover 336 of the first 500 terms.
LINKS
Gerhard Kirchner, Special periodic continued fractions
FORMULA
Formulas for some quadratic subsequences:
p,c formula first term a(1) thru a(500)
(k=1) frequency
4,1 (3k-1)^2 + 4k-1 a(1) = 7 125
5,1 (5k-2)^2 + 6k-2 a(2) = 13 75
3,2 (5k+1)^2 + 4k+1 a(4) = 41 74
4,2 (6k+1)^2 + 5k+1 a(5) = 55 62
EXAMPLE
7 = [2; [1, 1, 1, 4]]
13 = [3; [1, 1, 1, 1, 6]]
32 = [5; [1, 1, 1, 10]]
41 = [6; [2, 2, 12]]
55 = [7; [2, 2, 2, 14]]
MATHEMATICA
a:={}; For[k=0, k<2000, k++, b:=Last[ContinuedFraction[Sqrt[k]]]; p:=Length[b]; If[p>2, For[i=2, i<p&& Extract[b, 1]==Extract[b, i], i++, If[i==p-1, AppendTo[a, k]]]]]; a (* Stefano Spezia, Feb 04 2020 *)
PROG
(Maxima) block([an: 2, n: 0, nmax: 100],
/*transfers the first nmax terms to a file in the current directory*/
fl: openw(concat("terms-A331960-", nmax, ".txt")),
while n<nmax do
(an: an+1, w: sqrt(an), m: floor(w),
if w > m and mod(2*m, an-m^2)>0 then
(a: m, i: 0, x: w, ok: true,
while a<2*m and ok do
(i: i+1, x: 1/(x-floor(x)),
a: floor(x),
if i=1 then c: a
elseif a # c and a<2*m then ok: false),
if ok then(n: n+1, printf( fl, "~d, ", an)))),
close(fl));
CROSSREFS
KEYWORD
nonn
AUTHOR
Gerhard Kirchner, Feb 02 2020
STATUS
approved