2023-10-02

Why is answers is different?

I have answers of this code of finding Euler number:

import math 

Sn = 0

x = 1

big_n = 10000

for i in range(0,big_n,1):
    Sn = Sn + ((x**i)/(math.factorial(i)))

print(Sn)
print(math.e)

OUTPUT:

2.7182818284590455 2.718281828459045

Question:

Why is first output is for one digit more than second one?

I tried answer thats is becuz for math.e constant length but teacher says its not



No comments:

Post a Comment