Calculates the factorial of a number.
Contributed by @msranjana
def factorial(num):
if num < 0:
return "Factorial not defined for a negative number"
elif num == 0:
return 1
else:
fact = 1
for i in range(1, num + 1):
fact *= i
return fact
factorial(5) #120
factorial(-5) #Factorial not defined for a negative number