Skip to main content
1 of 2
GH from MO
  • 105.2k
  • 8
  • 292
  • 398

The probability depends on the parity of $n$ and the residue of $p$ modulo $4$: it can be calculated in a straightforward way using Gauss sums.

Let $n$ be $2k$ or $2k+1$, and let $p\equiv r\pmod{4}$ where $r=\pm 1$. Then, assuming I made no mistake, the probability equals $$ \frac{p+1}{2p}+\frac{p-1}{2p}(rp)^{-k}. $$

GH from MO
  • 105.2k
  • 8
  • 292
  • 398