Find the number of elements of order $p$, $p^2$, $p^3$, respectively in the group $\mathbb Z/p^3\mathbb Z \times \mathbb Z/p^2\mathbb Z$.
The answers are $p^2 − 1$, $p^4 − p^2$, $p^5 − p^4$, respectively. The key fact is that there are $p^3 − p^2$ elements of order $p^3$, $p^2 − p$ elements of order $p^2$, and $p − 1$ elements of order $p$ in $\mathbb Z/p^3\mathbb Z$.
How can I show the "why" of this answer? Similarly for $\mathbb Z/p^2\mathbb Z$.