scientific-programming-exer.../ex_09.py

19 lines
332 B
Python
Raw Normal View History

2018-11-07 14:22:04 +00:00
#!/usr/bin/python3
from math import gamma
def factorial(n):
n = int(n)
result = 1
if(n < 0):
raise ValueError("n must be greater than 0")
if(n == 0):
return result
for i in range(1, n + 1):
result *= i
return result
if( __name__ == "__main__"):
print("factorial(5) = ", factorial(5))
print("gamma(6) = ", gamma(6))