TITLE: Proving all primes are 1 or -1 modulo 6
QUESTION [13 upvotes]: Possible Duplicate:
Is that true that all the prime numbers are of the form $6m \pm 1$? 



Q. Why is it that all primes greater than 3 are either 1 or -1 modulo 6?


Does it suffice to argue as follows:
Let $p$ be a prime. $p>3 \Rightarrow 3$ does not divide $p$. Clearly $2$ does not divide $p$ either, and so 6 does not divide p. 
Now, $p$ is odd, and so $p$ is either 1,3 or 5 modulo 6. However, if $p$ were 3 (mod6), that would give us that $3$ divides $p$, which is a contradiction.
As such, we conclude that $p$ is either 1 or 5 (=-1) mod 6

REPLY [8 votes]: Yes. Generally if $\rm\:p\:$ is prime, then modulo $\rm\,2p,\,$ any prime $\rm\:q\ne 2,p\:$ must lie in one of the $\rm\:\phi(2p) = \phi(p) = p\!-\!1\:$ residue classes that are coprime to $2$ and $\rm p,$ i.e. all odd residue classes excluding $\rm p,\:$ viz.  $\rm\:1,3,5,\ldots,\hat p,\ldots,2p\!-\!1.\:$ Indeed, integers in other classes are divisible by $2$ or $\rm p\:$ hence, if prime, must be $2$ or $\rm p,\:$ resp.  More succinctly, exploiting negation reflection symmetry: $\rm\: q\equiv \pm\{1,3,5,\cdots,p\!-\!2\}\ \ (mod\ 2\:\!p),\ $ e.g. $\rm\,\ q\equiv \pm 1\ \ (mod\ 6),\:$ $\,\rm q\equiv \pm\{1,3\}\ \ (mod\ 10),\:$ $\,\rm q\equiv\pm \{1,3,5\}\ \ (mod\ 14),\:$ etc.
Generally, if $\rm\,q\,$ is any integer coprime to $\rm\:m\:$ then its remainder mod $\rm\:m\:$ lies in one of the $\rm\:\phi(m)\:$ residue classes coprime to $\rm\:m,\:$ where $\phi$ is the Euler totient function.