login
Continued fraction for sqrt(150).
0

%I #29 Feb 16 2025 13:01:54

%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 Block[{$MaxExtraPrecision=1000}, ContinuedFraction[Sqrt[150],300]] (* _Vladimir Joseph Stephan Orlovsky_, Mar 13 2011*) (* Program modified by _Harvey P. Dale_, Feb 16 2025 *)

%t PadRight[{12},120,{24,4}] (* _Harvey P. Dale_, Feb 16 2025 *)

%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,changed

%O 0,1

%A _N. J. A. Sloane_.