Find exponent of prime $p$ in prime factorization of a number $x$ Say we have a number $x$ such that
$$ x = a^{r}.b^{s}.c^{t}.p^{u} $$
Is there a formula or method which can directly give me the exponent of a particular prime in this prime factorization.
For small $x$ calculating it is not a problem but when $x$ is of the order of $10^{8}$ finding the exponent of a particular prime becomes tough.
e.g. For $p$ it should give $u$, for $a$ it should give $r$ and so on.
If somehow $x$ can be represented as $\frac{a!}{b!}$ then also it can be done.

Here's a suggestion: Compute powers $p$, $p^2$, $p^4$, … $p^{2^n}$, … by repeated squaring (note that each of these is the square of the preceding one), until $p^{2^{n+1}}\nmid x$. Then repeat the procedure with $x_1=x/p^{2^n}$, and so forth, until you arrive at a number not divisible by $p$. Now $a=2^{n+1}+\cdots$, where $\cdots$ is the sum of powers of $2$ obtained in each subsequent step.
