The following proof of Fermat's Little Theorem is taken verbatim from Fraleigh's A First Course in Abstract Algebra:
For any field, the nonzero elements form a group under the field multiplication. In particular, for $\mathbb Z_p$, the elements $$1,2,3,\ldots,p-1$$ form a group of order $p-1$ under multiplication modulo $p$. Since the order of any element in a group divides the order of the group, we see that for $b\neq0$ and $b\in\mathbb Z_p$, we have $b^{p-1}=1$ in $\mathbb Z_p$. Using the fact that $\mathbb Z_p$ is isomorphic to the ring of cosets of the form $a+p\mathbb Z$, we see at once that for any $a\in\mathbb Z$ not in the coset $0+p\mathbb Z$, we must have $$a^{p-1}\equiv1\pmod{p}.$$
I have no problem following the proof, except for one thing. The whole proof makes no mention at all about how $p$ must be a prime. Hence it seems like this proof demonstrates Fermat's Little Theorem for all numbers $p$, not just primes, which is absurd! Where precisely does this proof break down when $p$ is not prime? What am I missing? (Sorry if this question is too trivial, but I couldn't find an explanation elsewhere.)
the order of the multiplicative group $\bmod p$ is $\varphi(p)$ in general, it's just that if $p$ is prime we have $\varphi(p)=p-1$.
So in fact this is a proof of Euler's theorem.