Let $n\in\mathbb{N}$ with $n\ge 3$ and $a\in\mathbb{Z}$ such that $$a^{n-1}\equiv1\text{ mod } n\;\;\;\wedge\;\;\;a^{\frac{n-1}{p}}\not\equiv1\text{ mod }n\;\;\;\forall p\in\mathbb{P}:p\mid n-1$$ where $\mathbb{P}$ denotes the set of prime numbers $\Rightarrow$ $n\in\mathbb{P}$.
What does all that mean? Fermat's little theorem states, that if $p\in\mathbb{P}$, then it holds for all $a\in\mathbb{Z}$ with $p\nmid a$:$$a^{p-1}\equiv 1\text{ mod }p$$ It seem's like this has something in common with the statement above. However, we only know that the congruence is fulfilled for one specific $a$ and Fermat's little theorem doesn't help in this direction.
So, how would one argue?
The assumption implies that $a$ is an element of order $n-1$ in the multiplicative monoid $\mathbb{Z} / n \mathbb{Z}$. (If the order of $a$ were a proper divisor $m$ of $n-1$, consider a prime $p$ dividing $(n-1)/m$, and compute $a^{(n-1)/p} = (a^{m})^{(n-1)/(mp)} \equiv 1 \pmod{n}$, against the assumption.)
Since $a$ is invertible in $\mathbb{Z} / n \mathbb{Z}$, as $a \cdot a^{n-2} \equiv 1 \pmod{n}$, it follows that $\mathbb{Z} / n \mathbb{Z}$ is a field, and thus $n$ is prime.