For better intuition, let us work with particular numbers. We want the highest power of $3$ that divides $100!$, that is, $(1)(2)(3)(4)\cdots (99)(100)$.
For any number $k$ from $1$ to $100$, let $e_k$ be the highest power of $3$ that divides $k$. So for example $e_2=0$, $e_{12}=1$, $e_{63}=2$, and $e_{81}=4$. Then
$$e=e_1+e_2+e_3+\cdots+e_{99}+e_{100}.$$
To view things more concretely, suppose that each number $k$ has to pay a tax of $e_k$ dollars. Then $e$ is the total tax levied by the taxation authority.
First let us gather a tax of $1$ dollar from each multiple of $3$. We gather a total of $\left\lfloor \frac{100}{3}\right\rfloor$.
Now $3$, $6$, $12$, $15$, $\dots$ have paid what they owe. But $9$, $18$, $27$, $\dots$ still owe money, Let us gather a dollar from each of them. We get $\left\lfloor \frac{100}{9}\right\rfloor$ dollars.
But $27$, $54$, $81$ still owe money. Get a dollar from each. We get $\left\lfloor \frac{100}{27}\right\rfloor$ dollars.
But $81$ is still not fully paid up. We get an additional $\left\lfloor \frac{100}{81}\right\rfloor$ dollars. So the total tax $e$ paid is
$$\left\lfloor \frac{100}{3}\right\rfloor+\left\lfloor \frac{100}{9}\right\rfloor+\left\lfloor \frac{100}{27}\right\rfloor+\left\lfloor \frac{100}{81}\right\rfloor.$$
The story is the same for any prime. To see how many terms we will have in the sum, let $p^t$ be the highest power of $p$ which is $\le n$. So $t=\lfloor \log_p(n)\rfloor$. Then the highest amount of tax owed by any number in the interval $1$ to $n$ is $t$, and therefore the sum has $t$ terms.