← Back to List

15996번: 팩토리얼 나누기 ↗

Solutions

Python 3
160 B | 160 chars
n, k = map(int, input().split())

if n == 0:
    print(0)
else:
    ans = 0
    k2 = k
    while k2 <= n:
        ans += n // k2
        k2 *= k
    print(ans)