[Python] python使用连分数计算常数e →→→→→进入此内容的聊天室

来自 , 2020-11-08, 写在 Python, 查看 115 次.
URL http://www.code666.cn/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

回复 "python使用连分数计算常数e"

这儿你可以回复上面这条便签

captcha