19 lines
332 B
Python
19 lines
332 B
Python
|
#!/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))
|