How to display the given series in Python?
1 1 2 2 2 4 3 3 6 4 4 8....N terms.
Logic:
First two terms - 1 and 1, sum = 1 + 1 = 2. Third term = 2.
Next two terms - 2 and 2, sum = 2 + 2 = 4, sixth term = 4 etc.
Note: Don't use more than 1 print statement inside loop.
Answers
Answered by
1
Answer:
Program to find the sum of a Series 1/1! + 2/2! + 3/3! + 4/4! +…….+ n/n!
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
Recommended
Answered by
2
Program :
Explanation :
I am getting lists of sets like [1,1,2] , [2,2,4] , [3,3,6] ... etc using the loop as a and appending all such sets into a list l.
Now this list l is a nested so using list comprehension i have flattened it and then printing the n terms required.
Hope this helps : )
Similar questions