Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
def get_factorial(n):
if n < 0:
return -1 #if input is 0 break function
else:
factorial = 1
for i in range(1, n+1): # finds all number to multiply
factorial *= i # number multiplied by the indices
return factorial
def trailingZeros(n):
count = 0
i = 5
while(n//i != 0): # function continues until n is no longer divisibly by 5
count += int(n/i) # counts how many 5 there are
i = i * 5 # can be used for any number to figure out the zeros
return count
n = int(input("Type in a number: ")) # User input
fact = get_factorial(n)
print("The factorail number of your input is " + str(fact) + ".")
print("And the number of trailing zeros is: " + str(trailingZeros(n)))