Skip to content

Instantly share code, notes, and snippets.

@kenchangh
Created March 15, 2016 14:09
Show Gist options
  • Save kenchangh/0e397d616602a5282d87 to your computer and use it in GitHub Desktop.
Save kenchangh/0e397d616602a5282d87 to your computer and use it in GitHub Desktop.
Approximate exponent using continuous fractions
def approximate_exponent(end):
denominator = float(end) + 1
for i in xrange(end, 0, -1):
denominator = i + i/denominator
return 2+1/denominator
print approximate_exponent(2) # 2.72727272727
print approximate_exponent(3) # 2.71698113208
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment