"""
def factorial(x):
result = [1]
for i in range(1,x+1):
result.append(i*result[-1])
return result
if N == 0:
print('{:.8f}'.format(1))
else:
li = factorial(N)
s = sum([1/i for i in li])
print('{:.8f}'.format(s))
"""
def factorial(x):
result = [1]
if x == 0:
return result
else:
for i in range(1,x+1):
result.append(i*result[-1])
return result
N = int(input())
li = factorial(N)
s = sum([1/i for i in li])
print('{:.8f}'.format(s))
第四章 7-5 求e的近似值
最新推荐文章于 2024-04-03 23:32:38 发布