how to print factorial in python

Solutions on MaxInterview for how to print factorial in python by the best coders in the world

showing results for - "how to print factorial in python"
Giulio
30 Sep 2016
1#will output the factorial for an input
2
3num = int(input("give a number:"))
4new_num = num + 1
5
6factorial = 1
7
8# check if the number is negative, positive or zero
9if num < 0:
10   print("factorial does not exist")
11elif num == 0:
12   print("factorial of 0 is 1")
13else:
14   for i in range(1, new_num):
15       factorial = factorial*i
16   print("The factorial of" , num , "is" , factorial)