Last active
March 20, 2018 16:18
-
-
Save stepheweffie/95f7113965feeb965f1dda6c6215fb39 to your computer and use it in GitHub Desktop.
The factorial function without the factorial module in python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
n = input('Please provide a number n: ') | |
def factor_ial(number): | |
count = 1 | |
arr = list() | |
num = number + 1 | |
for i in range(int(num)): | |
if i == 1: | |
count += 1 | |
#print(i, i * count) | |
p = i * count | |
arr.append(p) | |
elif i > 1: | |
count += 1 | |
#print(i, count) | |
p = count * arr[-1] | |
arr.append(p) | |
#print(p) | |
print(arr[-2]) | |
return arr[-2] | |
n = int(n) | |
factor_ial(n) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment