Prime Power in a Factorial
Print the exponent of prime P in the factorization of N! (the largest e with Pe | N!).
Input: one line with two integers N and P.
Output: the exponent of P in N!.
Constraints:
- 1 ≤ N ≤ 1018
- 2 ≤ P ≤ 106, P prime
Sample Tests
Input 1
10 2
Output 1
8
Input 2
100 5
Output 2
24
Discussion (opens after you solve — no spoilers before)
No comments yet.