How to calculate the sum of 1! + 2! + 3! + ... + N!
📁 Advanced Python Topics, AI
Problem condition:
For a given natural n, calculate the sum of 1! + 2! + 3! + ... + n!. Only one loop can be used to solve this problem. The use of the math library is forbidden.
n = int(input())
n = 1
sum = 0
for a in range(1, n+1):
for b in range(1, a+1):
n = n * b
sum += n
No answers yet.
Log in to leave an answer