Computer Science, asked by yashmay15, 8 months ago

Write a Python code to input a number n and display sum of the following series….

1/2!+3/4!+5/6!...............................+n/(n+1)!

Answers

Answered by UtsabBera
0

Answer:

from math import factorial

n = int(input("Enter n: "))

x = 0

for i in range(1, n+1, 2):

   x = x + (i/(factorial(i+1)))

print("The answer is =", x)

Explanation:

Note: According to the series mentioned in the question the 'n' should be an odd number, otherwise the series will not make. In this code, if the user enters an even number it will show the answer assuming the 'n' as the previous odd number (of the even number that the user has entered).

Output:

Enter n: 9

The answer is = 0.6321205357142857

*math module is a built-in module in Python, you can use it without installing it.

Similar questions