num = int(input("Enter a number: ")) factorial = 1 total = 0 for x in range(0,num): x = x + 1 factorial = factorial * x total = total + factorial print(total) code example
Example: python calculate factorial
def factorial(n):
fact = 1
for num in range(2, n + 1):
fact = fact * num
return(fact)