Files
30-seconds-of-code/test/factorial/factorial.py
Rohit Tanwar 385bf72a3e readme-script
2018-02-20 22:42:11 +05:30

5 lines
210 B
Python

def factorial(num):
if not ((num >= 0) & (num % 1 == 0)):
raise Exception(
f"Number( {num} ) can't be floating point or negative ")
return 1 if num == 0 else num * factorial(num - 1)