Here this example tells how to calculate factorials in Python.
Source Code
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
# define the function of calculating factorial
def factorial(a):
if a>=1:
return factorial(a-1)*a
else:
return 1
# sum up factorials
sum = 0
a = int(input("please input your num: "))
for i in range(1,a):
sum += factorial(i)
print(sum)
Output:
please input your num: 9
46233