Int get powers(n, p)

Explanation
The exponent of a prime p in n! is $$\sum_{k=1}^{\lfloor log_pN\rfloor} \lfloor \frac{N}{p^{k}}\rfloor$$

See
SPOJ_FCTRL

UVa_10139 - NB! int could overflow. See alternative implementation

UVa_160