login
a(n) is the least k such that the continued fraction for sqrt(k) has periodic part [r, 1, 2, ..., n-1, n, n-1, ..., 1, 2r] for some positive integer r.
1

%I #19 Feb 09 2022 16:40:45

%S 3,14,216,25185,23287359,1953082923,81112983931776,6667182474680388,

%T 699567746120736710880,855784807474766398870755,

%U 51592564054278677032777194015,1474855822717073602911008555048040,23175672095781915301598668218548941215,474577479777785868138090462593743556930231

%N a(n) is the least k such that the continued fraction for sqrt(k) has periodic part [r, 1, 2, ..., n-1, n, n-1, ..., 1, 2r] for some positive integer r.

%e a(3) = 216 because the continued fraction of sqrt(216) has periodic part [14; 1, 2, 3, 2, 1, 28] and this is the least number with this property.

%o (Python)

%o from itertools import count

%o from sympy.ntheory.continued_fraction import continued_fraction_reduce

%o def A351139(n):

%o if n == 2:

%o return 14

%o for r in count(1):

%o if (k := continued_fraction_reduce([r,list(range(1,n+1))+list(range(n-1,0,-1))+[2*r]])**2).is_integer:

%o return k # _Chai Wah Wu_, Feb 09 2022

%Y Cf. A013646.

%K nonn

%O 1,1

%A _Giorgos Kalogeropoulos_, Feb 02 2022