KnowledgeBoat Logo
|

Robotics & Artificial Intelligence

Write Python code to find the sum of the given series:

S = 1! + 2! + 3! + 4! + …………… + n!

[Hint: Factorial of 5! = 5*4*3*2*1]

Python Control Flow

3 Likes

Answer

n = int(input("Enter the value of n: "))
s = 0
f = 1

for i in range(1, n+1):
    f = f * i
    s = s + f

print("Sum of the series =", s)

Output

Enter the value of n: 6
Sum of the series = 873

Answered By

3 Likes


Related Questions