aboutsummaryrefslogtreecommitdiff
path: root/challenge-072/walt-mankowski/python/ch-1.py
blob: 51106843adc54200913e31da16d6f2575d18d096 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
from sys import argv

def fact(n):
    res = 1
    for i in range(2, n+1):
        res *= i
    return res

def num_trailing_zeros(n):
    cnt = 0
    pwr = 10
    while n % pwr == 0:
        cnt += 1
        pwr *= 10
    return cnt

n = int(argv[1])
f = fact(n)
z = num_trailing_zeros(f)
zeros = "zero" if z == 1 else "zeros"
print(f"{n} as N! = {f} has {z} trailing {zeros}")