Prime exponent in factorial
Your task
Given a number n and a prime p, return the exponent of p in the prime factorization of n! (n factorial) using Legendre's formula: sum over k>=1 of floor(n / p^k). Do NOT compute n! itself (it would overflow instantly). For p=5 this also equals the number of trailing zeros of n! when paired with the (larger) power of 2. Constraints: 0 <= n <= 10^9, p is a prime <= 10^9.
Examples
prime_power_in_factorial(n: int, p: int) -> intExample 1
Input
prime_power_in_factorial(100, 5)Output
24