I'm trying to find all non-negative integers $n$ satisfying $2^{n}\equiv n^{2}\pmod{5}$.
So far, all the progress I've made is figuring out that $n^{2} mod \, 5$ for $n=1$ to $5$ has the pattern "$1,\, 4,\, 4,\, 1,\, 0$" which repeats $mod \, 5$. Then, I started looking at powers of $2$ to see if there was a pattern to when they are $0,\,1,\,\text{and}\, -1\, mod\, 5$. I saw that when $n = 4k$, where $k$ is an integer $\geq 0$, $2^{n}\,mod\,5 = 1$; for $n=5k$, where $k$ is an integer $\geq 0$, $2^{n} \, mod\, 5 = -1$; and there exists no $n$ such that $2^{n} \,mod\, 5 = 0$.
But, I found no pattern as to when $2^{n}\mod 5 = n^{2}\,\mod\,5$, so then I can find all the $n$'s that give me the divisibility I want.
No hints, please, I'm not a number theorist and am really out of my comfort zone. Just complete answers, so I can figure out how problems that look like this are supposed to be done.
Thank you in advance
The powers of $2$ mod $5$ repeat with period $4$, and the squares repeat with period $5$. Thus $(2^n - n^2) \mod 5$ repeats with period $20$. For $0 \le n \le 19$ you get $$ \matrix{n & 0 & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 & 11 & 12 & 13 & 14 & 15 & 16 & 17 & 18 & 19 \cr n^2 \mod 5 & 0 & 1 & 4 & 4 & 1 & 0 & 1 & 4 & 4 & 1 & 0 & 1 & 4 & 4 & 1 & 0 & 1 & 4 & 4 & 1 \cr 2^n \mod 5 & 1 & 2 & 4 & 3 & 1 & 2 & 4 & 3 & 1 & 2 & 4 & 3 & 1 & 2 & 4 & 3 & 1 & 2 & 4 & 3 \cr}$$ Thus $2^n \equiv n^2 \mod 5$ for $n \equiv 2, 4, 16$, or $18 \mod 20$.