If
\[p \gt 3\]
is prime then\[(3/p) = \{ \begin{array}{c} 1 \; if \; p \equiv 1 \; (mod \; 12) \; or \; p \equiv 11 \; (mod \; 12) \\ -1 \; if \; p \equiv 5 \; (mod \; 12) \; or \; p \equiv 7 \; (mod \; 12) \end{array} \]
Proof
We use the Law of Quadratic Reciprocity
\[(p/q)(q/p)=(-1)^{(p-1)(q-1)/4}\]
with \[q=3\]
.\[(p/3)(3/p)=(-1)^{(3-1)(p-1)/4}=(-1)^{(p-1)/2}\]
The only quadratic residue of 3 is 1, and the only quadratic non residue is 2.
Let
\[p=1 \; (mod \; 3)\]
.
\[(p/3)(3/p)=1 \times (3.p)=(-1)^{(p-1)/2}\]
\[(3/p)=(-1)^{(p-1)/2}\]
Then
\[(3/p)=1\]
if and only if \[\frac{p-1}{2}=2k \rightarrow p=4k+1\]
Then
\[p \equiv 1 (mod \ 3), \; p \equiv 1 (mod \ 4) \rightarrow p \equiv 1 (mod \ 12)\]
Let
\[p=2 \; (mod \; 3)\]
.
\[(p/3)(3/p)=-1 \times (3/p)=(-1)^{(p-1)/2}\]
\[-(3/p)=(-1)^{(p-1)/2}\]
Then
\[(3/p)=1\]
if and only if \[\frac{p-1}{2}=2k+1 \rightarrow p=4k+3\]
Then
\[p \equiv 2 (mod \ 3), \; p \equiv 3 (mod \ 4) \rightarrow p \equiv 11 (mod \ 12)\]
Let
\[p=1 \[ (mod \; 3)\]
.
\[(p/3)(3/p)=1 \times (3/p)=(-1)^{(p-1)/2}\]
\[(3/p)=(-1)^{(p-1)/2}\]
Then
\[(3/p)=-1\]
if and only if \[\frac{p-1}{2}=2k+1 \rightarrow p=4k+3\]
Then
\[p \equiv 1 (mod \ 3), \; p \equiv 3 (mod \ 4) \rightarrow p \equiv 7 (mod \ 12)\]
Let
\[p=2 \; (mod \; 3)\]
.
\[(p/3)(3/p)=-1 \times (3/p)=(-1)^{(p-1)/2}\]
\[-(3/p)=(-1)^{(p-1)/2}\]
Then
\[(3/p)=-1\]
if and only if \[\frac{p-1}{2}=2k \rightarrow p=4k+3\]
Then
\[p \equiv 1 (mod \ 3), \; p \equiv 1 (mod \ 4) \rightarrow p \equiv 5 (mod \ 12)\]