python使用连分数计算常数e
# Calculating e using Continued Fraction # http://www.75271.com import math n = 18 # number of iterations x = 0.0 for i in range(n, 0, -1): if i % 3 == 1: j = int(i / 3) * 2 else: j = 1 x = 1.0 / (x + j) print x + 1, math.e
python使用连分数计算常数e
# Calculating e using Continued Fraction # http://www.75271.com import math n = 18 # number of iterations x = 0.0 for i in range(n, 0, -1): if i % 3 == 1: j = int(i / 3) * 2 else: j = 1 x = 1.0 / (x + j) print x + 1, math.e