Added function to get factorial of number

This commit is contained in:
2021-06-01 18:31:10 -04:00
parent a7c4346af5
commit 0bbb7ff9bf
2 changed files with 30 additions and 3 deletions

View File

@@ -229,3 +229,10 @@ def gcd(num1: int, num2: int) -> int:
else:
num2 %= num1
return num1 | num2
#Returns the factorial of the number passed in
def factorial(num: int) -> int:
fact = 1
for cnt in range(1, num + 1):
fact *= cnt
return fact