+ 1
problem in python please help
cant find the answer.....it should come 2.718......, but its coming 2.58..... please help guyx\ link https://code.sololearn.com/c7nrC68pIrot/#py
3 Respostas
+ 2
Delete the 2nd "for" and change the variable "mul" to "n". Here the code:
https://code.sololearn.com/cRdK298t578V/?ref=app
+ 5
Remove line 10 and put "fact = 1" after first for loop. You can also use math.factorial to calculate it.
+ 5
2 versions:
1) using math. factorial()
2) own factorial calculation
import math
end = 100
total = 1
for i in range(1, end+1):
total = total + 1/math.factorial(i)
print(total)
total = 1
for i in range(1, end):
fact = 1
for j in range(1,i+1):
fact *= j
total = total +1 / fact
print(total)
https://code.sololearn.com/cai8R4M1Ap8p/?ref=app