Python Program to Find the Sum of the Series 1/1!+1/2!+1/3!+…1/N!

This is a Python Program to find the sum of series: 1/1!+1/2!+1/3!+…1/N!.

Problem Description

The program takes in the the number of terms and finds the sum of series: 1/1!+1/2!+1/3!+…1/N!.

Problem Solution

1. Take in the number of terms to find the sum of the series for.
2. Initialize the sum variable to 1.
3. Use a for loop ranging from 1 to the number and find the sum of the series.
4. Print the sum of the series after rounding it off to two decimal places.
5. Exit.

Program/Source Code

Here is source code of the Python Program to find the sum of series: 1/1!+1/2!+1/3!+…1/N!. The program output is also shown below.

import math
n=int(input("Enter the number of terms: "))
sum1=1
for i in range(1,n+1):
    sum1=sum1+(1/math.factorial(i))
print("The sum of series is",round(sum1,2))
Program Explanation

1. User must enter the number of terms to find the sum of.
2. The sum variable is initialized to 1.
3. The for loop is used to find the sum of the series and the number is incremented for each iteration.
4. The numbers are added to the sum variable and this continues till the value of i reaches the number of terms.
5. Then the sum of the series is printed.

advertisement
Runtime Test Cases
 
Case 1:
Enter the number of terms: 5
The sum of series is 2.72
 
Case 2:
Enter the number of terms: 20
The sum of series is 2.72

Sanfoundry Global Education & Learning Series – 1000 Python Programs.

If you wish to look at all Python Programming examples, go to 1000 Python Programs.

⚡ Claim Your Free Java Certification - December 2025

advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
I’m Manish - Founder and CTO at Sanfoundry. I’ve been working in tech for over 25 years, with deep focus on Linux kernel, SAN technologies, Advanced C, Full Stack and Scalable website designs.

You can connect with me on LinkedIn, watch my Youtube Masterclasses, or join my Telegram tech discussions.

If you’re in your 20s–40s and exploring new directions in your career, I also offer mentoring. Learn more here.