login
Continued fraction for sqrt(150).
0

%I #27 Dec 26 2023 23:59:40

%S 12,4,24,4,24,4,24,4,24,4,24,4,24,4,24,4,24,4,24,4,24,4,24,4,24,4,24,

%T 4,24,4,24,4,24,4,24,4,24,4,24,4,24,4,24,4,24,4,24,4,24,4,24,4,24,4,

%U 24,4,24,4,24,4,24,4,24,4,24,4,24,4,24,4,24,4,24,4

%N Continued fraction for sqrt(150).

%H <a href="/index/Con#confC">Index entries for continued fractions for constants</a>

%H <a href="/index/Rec#order_02">Index entries for linear recurrences with constant coefficients</a>, signature (0,1).

%p Digits := 100: convert(evalf(sqrt(N)),confrac,90,'cvgts'):

%t ContinuedFraction[Sqrt[150],300] (* _Vladimir Joseph Stephan Orlovsky_, Mar 13 2011*)

%o (Python)

%o from sympy import sqrt

%o from sympy.ntheory.continued_fraction import continued_fraction_iterator

%o def aupton(nn):

%o gen = continued_fraction_iterator(sqrt(150))

%o return [next(gen) for i in range(nn+1)]

%o print(aupton(73)) # _Michael S. Branicky_, Dec 04 2021

%o (Python) # second version based on recurrence

%o def a(n): return 12 if n == 0 else [4, 24][(n-1)%2]

%o print([a(n) for n in range(74)]) # _Michael S. Branicky_, Dec 04 2021

%K nonn,cofr,easy

%O 0,1

%A _N. J. A. Sloane_.