Let $k,n\in \mathbb Z$ with $n=k^2+1$ and let $p$ be an odd prime with $p\mid n$. Prove that $p\equiv1\text{ mod }4$.
I found out that $\bar{n}\in\left\{ \bar{1},\bar{2}\right\} $ (denoting $r+4\mathbb{Z}$ by $\bar{r}$) but there it stops for me.
Actually I suspect that it can be used as a step in proving that infinitely primes with $p\equiv1\text{ mod }4$ exist, but here I am only interested in the step itself.
Thank you in advance.
Modulo $p$ we have $1 \equiv k^{p-1} \equiv (k^2)^{(p-1)/2} \equiv (-1)^{(p-1)/2}$ and hence $p \equiv 1 \pmod 4$.