Python uses continued fraction to calculate constant e

From , 3 Years ago, written in Python, viewed 51 times.
URL https://pastebin.vip/view/166cee72
  1. # Calculating e using Continued Fraction
  2. # http://www.sharejs.com
  3. import math
  4. n = 18 # number of iterations
  5. x = 0.0
  6. for i in range(n, 0, -1):
  7.  
  8.     if i % 3 == 1:
  9.         j = int(i / 3) * 2
  10.     else:
  11.         j = 1
  12.  
  13.     x = 1.0 / (x + j)
  14.  
  15. print x + 1, math.e
  16.  
  17. #//python/8630

Reply to "Python uses continued fraction to calculate constant e"

Here you can reply to the paste above

captcha

https://burned.cc - Burn After Reading Website