Exponent of $p$ in the prime factorization of $n!$ is given by $\large \sum \limits_{i=1}^{\lfloor\log_p n \rfloor } \left\lfloor \dfrac{n}{p^i}\right\rfloor $.
Can this sum be simplified further to some direct expression so that the number of calculations are reduced?
Answer
yes:
$$
\frac{N-\sigma_p(N)}{p-1}
$$
where $\sigma_p(N)$ is the sum of digits in the $p$-ary expression of $N$
No comments:
Post a Comment