= Number of consecutive nonzero quadratic residues modulo an odd prime
For an <odd prime> $p$, the number of <integers> $z\in\{1,\ldots,p-2\}$ such that both $z$ and $z+1$ are <quadratic residues> modulo $p$ is
$$
\frac{p-4-(-1)^{(p-1)/2}}4.
$$
For example, modulo $11$ the <quadratic residues> are $1,3,4,5,9$. The qualifying pairs are $(3,4)$ and $(4,5)$, giving $(11-4+1)/4=2$.
Write $\chi$ for the <Legendre symbol>. On the specified range neither input is zero, so the indicator of the required event is $(1+\chi(z))(1+\chi(z+1))/4$. Expand and sum. The <complete Legendre-symbol sum> gives
$$
\sum_{z=1}^{p-2}\chi(z)=-\chi(-1),\qquad
\sum_{z=1}^{p-2}\chi(z+1)=-1.
$$
The <quadratic Legendre-symbol correlation> gives $\sum_{z=1}^{p-2}\chi(z)\chi(z+1)=-1$: extending to the full <finite field> only adds the zero terms at $z=0,-1$. Thus the count is $(p-2-\chi(-1)-1-1)/4$. The <first supplementary law for quadratic reciprocity> identifies $\chi(-1)=(-1)^{(p-1)/2}$ and completes the formula.
Back to article page