login
Least even number k such that the continued fraction for sqrt(k) has period n.
2

%I #12 Jul 11 2021 12:19:44

%S 2,6,130,14,74,22,58,44,106,86,298,46,746,134,1066,94,1018,424,922,

%T 268,394,166,586,382,1306,214,1354,334,1642,436,2122,508,1114,454,

%U 4138,478,3194,1108,4874,526,3418,724,2458,604,9914,694,4618,844,2746,1318

%N Least even number k such that the continued fraction for sqrt(k) has period n.

%H Chai Wah Wu, <a href="/A288185/b288185.txt">Table of n, a(n) for n = 1..10000</a>

%H Eric Weisstein's World of Mathematics, <a href="http://mathworld.wolfram.com/PeriodicContinuedFraction.html">Periodic Continued Fraction</a>

%F A003285(a(n)) = n, A000035(a(n)) = 0.

%e a(2) = 6, sqrt(6) = 2 + 1/(2 + 1/(4 + 1/(2 + 1/(4 + 1/...)))), period 2: [2, 4].

%o (Python)

%o from sympy import continued_fraction_periodic

%o def A288185(n):

%o d = 2

%o while True:

%o s = continued_fraction_periodic(0,1,d)[-1]

%o if isinstance(s, list) and len(s) == n:

%o return d

%o d += 2 # _Chai Wah Wu_, Jun 08 2017

%Y Cf. A000035, A003285, A010337-A010339, A013642-A013644, A013646, A013943, A020347-A020439, A097853, A240072, A288184.

%K nonn

%O 1,1

%A _Ilya Gutkovskiy_, Jun 06 2017