For20. An integer N (>0) is given. Using one cycle, find the sum
\(1! + 2! + 3! + ... + N!\)
(The expression N! - N-factorial - denotes the product of all integers from 1 to N: \(N! = 1 \cdot 2 \cdot ... \cdot N\)). To avoid an integer overflow, perform calculations by using of real variables and print the result as a real number.

Solution in Python 3:

import random

N = random.randrange(1,10)
print('N = ', N)

F = 1.0
S = 0.0
for i in range(1,N+1):
F *= i
S += F
print(i," : ", F," : ", S)
print("Result:",S)