Skip to main content
added 30 characters in body
Source Link
loopy walt
  • 16.8k
  • 2
  • 11
  • 69

Python, 8584 bytes

def f(x):
 g=i=999;s=1g=i=999;s=1|-2*(x>1);x=x**s-1
 while i:g=i+x*(i*i/g-(i:=i-1))
 return x*s/g

Attempt This Online!Attempt This Online!

Thanks @xnor for -1.

How?

Evaluates a continued fraction https://en.wikipedia.org/wiki/Euler%27s_continued_fraction_formula

Python, 85 bytes

def f(x):
 g=i=999;s=1-2*(x>1);x=x**s-1
 while i:g=i+x*(i*i/g-(i:=i-1))
 return x*s/g

Attempt This Online!

How?

Evaluates a continued fraction https://en.wikipedia.org/wiki/Euler%27s_continued_fraction_formula

Python, 84 bytes

def f(x):
 g=i=999;s=1|-(x>1);x=x**s-1
 while i:g=i+x*(i*i/g-(i:=i-1))
 return x*s/g

Attempt This Online!

Thanks @xnor for -1.

How?

Evaluates a continued fraction https://en.wikipedia.org/wiki/Euler%27s_continued_fraction_formula

Source Link
loopy walt
  • 16.8k
  • 2
  • 11
  • 69

Python, 85 bytes

def f(x):
 g=i=999;s=1-2*(x>1);x=x**s-1
 while i:g=i+x*(i*i/g-(i:=i-1))
 return x*s/g

Attempt This Online!

How?

Evaluates a continued fraction https://en.wikipedia.org/wiki/Euler%27s_continued_fraction_formula