Q. Write a python program to sum the sequence:
1 + 1/1! + 1/2! + 1/3! + …….. + 1/n!
You can understand by Watching video :-
Answer :-
n = int(input("Enter a n = "))
fact = 1
sum = 1
for i in range(1, n + 1):
fact = fact * i
sum = sum + 1 / fact
print("Sum of sequence = ", sum)
Output :-
Enter n= 8
Sum of sequence = 2.71827876984127
>>>
Enter n= 40
Sum of sequence = 2.7182818284590455
>>>
Post a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )