Question
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.
prime_power_in_factorial(n: int, p: int) → int[100,5]out24State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.
Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.