If $p^2-n^2$ is divisible $12$, where $p$ is prime, does that mean that $n$ is a prime? Except for 2 and 3.
If you square a prime, subtract from it the square of another prime, and divide it by 12, the result is always integer, right?
Would this work for testing whether a possible prime with n digits is indeed prime?
 A: Consider numbers of the form $6k\pm 1$. All primes greater than $3$ are of that form, but not all numbers of that form are primes. For $m>n$ compute
$$(6m\pm 1)^2-(6n\pm 1)^2=(36m^2\pm 12m +1)-(36n^2\pm 12n +1)\\ =36(m^2-n^2)\pm 12(m\pm n)$$
That difference is plainly divisible by $12$, whether or not neither, one, or both of $(6m\pm 1)$ and $(6n\pm 1)$ are primes.
So the test does not comment on the primeness of a number.
A: Suppose $n$ is an integer that is divisible by neither $2$ nor $3$.  Then $$n^2-1=(n+1)(n-1)$$ is divisible by $12$: since $n$ is odd, both factors are even, and since $n$ is not divisible by $3$, one of the factors is divisible by $3$.  (There are many other easy ways to verify this as well, for instance using modular arithmetic.)  It follows that if you have two such integers $n$ and $m$, then $$n^2-m^2=(n^2-1)-(m^2-1)$$ is also divisible by $12$.
So, your statement works not just primes other than $2$ and $3$, but for all integers that are divisible by neither $2$ nor $3$.
