Using Gauss' lemma show when $p$ is an odd prime, one has $$\left(\frac{2}{p}\right)=(-1)^{(p^2-1)/8}$$
The proof starts with let $a=2$ in gauss' lemma, then one has
$$ a_j = \begin{cases} 2j, & \text{when $1\leq j\leq [p/4]$} \\ 2j-p, & \text{when $[p/4]<j\leq(p-1)/2$} \end{cases} $$
I am not sure where the $[p/4]$ comes from. Can someone break down where the values for $a_j$ come from.
In this lemma $a_j$ gives a specific representant of $2j$ modulo $p$. This is the unique representant between $-\frac{p-1}{2}\leq a_j\leq \frac{p-1}{2}$. Just try for $p=11$ and $p=13$ :
$$p=11 $$
$j=1,...,\frac{p-1}{2}=5$ you get :
$$a_1=2=2\times 1$$
$$a_2=4=2\times 2$$
$$a_3=6=-5=2\times 3-11 $$
$$a_4=8=-3=2\times 4-11 $$
$$a_5=10=-1=2\times 5-11 $$
Hence for $j=1,2$ you have that $2j$ is below $\frac{p-1}{2}$ and for $j=3,4,5$ you have that $2j-p$ is in the good range. Remark that $p/4=2.75$ that is below $2$, $2j$ is okay and above the good representant is $2j-p$.
$$p=13 $$
$j=1,...,\frac{p-1}{2}=6$ you get :
$$a_1=2=2\times 1$$
$$a_2=4=2\times 2$$
$$a_3=6 $$
$$a_4=8=-5=2\times 4-13 $$
$$a_5=10=-3=2\times 5-13 $$
$$a_6=12=-1=2\times 6-13 $$