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

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

loopy walt
  • 16.8k
  • 2
  • 11
  • 69