Computer Science
Write a Python program to sum the sequence:
1 + 1/1! + 1/2! + 1/3! + ….. + 1/n! (Input n)
Python
Python Control Flow
53 Likes
Answer
n = int(input("Enter the value of n: "))
sum = 0
for i in range(n + 1) :
fact = 1
for j in range(1, i) :
fact *= j
term = 1 / fact
sum += term
print("Sum =", sum)
Output
Sum = 3.708333333333333
Answered By
30 Likes
Related Questions
Write programs to find the sum of the following series:
x - x2/2! + x3/3! - x4/4! + x5/5! - x6/6! (Input x)
Write Python programs to sum the given sequences:
12 + 32 + 52 + ….. + n2 (Input n)
Write a program to accept the age of n employees and count the number of persons in the following age group:
(i) 26 - 35
(ii) 36 - 45
(iii) 46 - 55Write Python programs to sum the given sequences:
2/9 - 5/13 + 8/17 …… (print 7 terms)