Skip to content

Instantly share code, notes, and snippets.

@stepheweffie
Last active March 20, 2018 16:18
Show Gist options
  • Save stepheweffie/95f7113965feeb965f1dda6c6215fb39 to your computer and use it in GitHub Desktop.
Save stepheweffie/95f7113965feeb965f1dda6c6215fb39 to your computer and use it in GitHub Desktop.
The factorial function without the factorial module in python
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