Open In App

Python Program for Program to find the sum of a Series 1/1! + 2/2! + 3/3! + 4/4! +…….+ n/n!

Last Updated : 11 Aug, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

You have been given a series 1/1! + 2/2! + 3/3! + 4/4! +…….+ n/n!, find out the sum of the series till nth term. Examples:

Input :n = 5
Output : 2.70833

Input :n = 7
Output : 2.71806

Python3




# Python code to find smallest K-digit 
# number divisible by X
 
def sumOfSeries(num):
     
    # Computing MAX
    res = 0
    fact = 1
     
    for i in range(1, num+1):
        fact *= i
        res = res + (i/ fact)
         
    return res
     
 
n = 5
print("Sum: ", sumOfSeries(n))
 
# Code contributed by Mohit Gupta_OMG <(0_o)>


Output:

Sum: 2.70833

Time Complexity: O(N)

Auxiliary Space: O(1)

Please refer complete article on Program to find the sum of a Series 1/1! + 2/2! + 3/3! + 4/4! +…….+ n/n! for more details!


Similar Reads

Python Program for Find sum of Series with n-th term as n^2 - (n-1)^2
We are given an integer n and n-th term in a series as expressed below: Tn = n2 - (n-1)2 We need to find Sn mod (109 + 7), where Sn is the sum of all of the terms of the given series and, Sn = T1 + T2 + T3 + T4 + ...... + Tn Examples: Input : 229137999 Output : 218194447 Input : 344936985 Output : 788019571 Let us do some calculations, before writi
2 min read
Python program to find the sum of sine series
Prerequisite: math Given n and x, where n is the number of terms in the series and x is the value of the angle in degree. The Task here is, write a program to calculate the sum of sine series of x. Formula Used: [Tex]sinx=x–(x3/3!)+(x5/5!)–(x7/7!)+…[/Tex] Example: Input: n = 10 x = 30 Output: sum of sine series is 0.5 Input: n = 10 x = 60 Output: s
1 min read
Python | Find fibonacci series upto n using lambda
The Fibonacci numbers are the numbers in the following integer sequence. 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, ........ In mathematical terms, the sequence Fn of Fibonacci numbers is defined by the recurrence relation Fn = Fn-1 + Fn-2 with seed values F0 = 0 and F1 = 1. Find the series of fibonacci numbers using lambda function. Code #1 : B
2 min read
Python Program for Print Number series without using any loop
Problem - Givens Two number N and K, our task is to subtract a number K from N until number(N) is greater than zero, once the N becomes negative or zero then we start adding K until that number become the original number(N). Note : Not allow to use any loop. Examples : Input : N = 15 K = 5 Output : 15 10 5 0 1 5 10 15 Input : N = 20 K = 6 Output :
3 min read
Fibonacci Series Program In Python Using Iterative Method
Fibonacci series is a series where each number is the sum of its two previous numbers. In this article, we are going to generate Fibonacci series in Python using Iterative methods. We will be covering both the loops i.e. for loop and while loop. In this article, we will be covering all the concepts related to the topic with clear and concise exampl
4 min read
Python Program for nth multiple of a number in Fibonacci Series
Given two integers n and k. Find position the nth multiple of K in the Fibonacci series. Examples: Input: k = 2, n = 3Output: 9, 3rd multiple of 2 in Fibonacci Series is 34 that appears at position 9. Input: k = 4, n = 5 Output: 30, 5th multiple of 4 in Fibonacci Series is 832040 which appears at position 30. An Efficient Solution is based on the b
5 min read
Python | Series K divisible elements
The problem focused in this article is quite specific and may be less useful in different domains. But the way this is going to solve may open doors to solve potentially like problems, hence making it worth a read. This article solves the problem of testing if a list contains series of K divisible. Let’s discuss certain ways in which this problem c
3 min read
Fibonacci Series In Python Using For Loop'
The Fibonacci series is a sequence of numbers in which each number is the sum of the two preceding ones, usually starting with 0 and 1. The sequence goes as follows: 0, 1, 1, 2, 3, 5, 8, 13, 21, and so on. This series is not only intriguing due to its inherent mathematical properties but also widely used in various fields such as mathematics, compu
3 min read
Python program to find Cumulative sum of a list
The problem statement asks to produce a new list whose i^{th} element will be equal to the sum of the (i + 1) elements. Examples : Input : list = [10, 20, 30, 40, 50]Output : [10, 30, 60, 100, 150]Input : list = [4, 10, 15, 18, 20]Output : [4, 14, 29, 47, 67] Approach 1 : We will use the concept of list comprehension and list slicing to get the cum
4 min read
Python Program for Find sum of even factors of a number
Given a number n, the task is to find the even factor sum of a number. Examples: Input : 30 Output : 48 Even dividers sum 2 + 6 + 10 + 30 = 48 Input : 18 Output : 26 Even dividers sum 2 + 6 + 18 = 26 Let p1, p2, … pk be prime factors of n. Let a1, a2, .. ak be highest powers of p1, p2, .. pk respectively that divide n, i.e., we can write n as n = (
4 min read
Article Tags :