TITLE: Using Fermats Little Theorem to show $2^{17} -1$ is prime
QUESTION [6 upvotes]: Show that $n = 2^{17} - 1$ is prime by using Fermat's Little Theorem $2^{p-1} \equiv 1 \mod p$ for any $p$ dividing $n$.

I said, that by FLT, we get $2^{16} \equiv 1 \mod 17$, and we can see that $1 \equiv 1 \mod 17$ and so we get
$$n = 1 - 1 = 0 \mod 17$$
but then all this tells me is that $n = 17k$ for some $k$ and not that it is prime. Where have I gone wrong?

REPLY [2 votes]: If $p|n$ is prime, then $2^{p-1}\equiv 1\pmod p$, but also $2^{17}\equiv 1\pmod p$, 
hence if $k=(p-1)a+17b$ then $2^k\equiv 1\pmod p$.
If $p-1$ is not a multiple of $17$, we can find such a linear combination with $k=a(p-1)+b17=1$, i.e. $2\equiv 1\pmod p$, contradiction.
Therefore $p\equiv1\pmod{17}$ for any $p|n$.
Now use trial divisions with primes of the form $p=17m+1<\sqrt n\approx 362$, that is $p=103$, $137$, $239$, and $307$.