Method 1: Use while loop to calculate
n = int(input()) jie = 1 sum = 0 i = 1 while n >= i: jie = jie * i sum = sum + jie i = i + 1 print(sum)
Method 2: Summing by calling the factorial method using a recursive function (where the value of n is between 1 and 40)
def jie(n): if n == 1: return 1 else: return n*jie(n-1) n = int(input()) sum = 0 if n < 1 or n > 40: print("Please re-enter the data.") else: for i in range(1,n+1): sum = sum + jie(i) print(sum)
This above python method to calculate factorial sum (1!+2!+3!+... +n!) is all that I have shared with you.