+ 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

10th Jun 2019, 6:31 PM
Rahul guha
Rahul guha - avatar
3 Respostas
+ 2
Delete the 2nd "for" and change the variable "mul" to "n". Here the code: https://code.sololearn.com/cRdK298t578V/?ref=app
11th Jun 2019, 1:12 AM
Cristian Baeza Jimenez
Cristian Baeza Jimenez - avatar
+ 5
Remove line 10 and put "fact = 1" after first for loop. You can also use math.factorial to calculate it.
10th Jun 2019, 6:57 PM
Mert Yazıcı
Mert Yazıcı - avatar
+ 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
10th Jun 2019, 7:42 PM
Lothar
Lothar - avatar