This is a direct application of Legendre's formula.
For any factorial, the largest exponent of a prime number say ‘p’ in the factorial of any number say ‘x’ can be found out using the formula shown below:
$\left \lfloor \dfrac{x}{p} \right \rfloor + \left \lfloor \dfrac{x}{p^{2}} \right \rfloor + \left \lfloor \dfrac{x}{p^{3}} \right \rfloor+ …. until \: becomes \:zero$
Logical Proof: Suppose you want to find exponent of 2 in 10! i.e. $1.2.3.4.5.6.7.9.10$
Then 2,4,6,8 and 10 will contribute single 2. Therefore we have 5 twos.
BUT BUT BUT, 4 has one more 2 to contribute. And similarly, 8 has 2 more twos to contribute,
Therefore when we do $\left \lfloor \dfrac{10}{4} \right \rfloor $ we cover one 2 of 4 and one 2 of 8 (since 4 is a factor of 8).
Similarly when we do $\left \lfloor \dfrac{10}{8} \right \rfloor $ we cover the third 2 of 8.
And therefore $\left \lfloor \dfrac{10}{2} \right \rfloor + \left \lfloor \dfrac{10}{2^{2}} \right \rfloor + \left \lfloor \dfrac{10}{2^{3}} \right \rfloor=8$, which means 2 has exponent 8 in the 10!.
NOTE: For finding out the exponent of any non-prime number, first find the exponent of its prime factors and then using the concept of bottleneck (i.e.whichever factor is limiting needs to be considered) derive the exponent.