The remainder of $1^1+2^2+3^3+\dots+98^{98}$ mod $4$ How can I solve this problem: 

If the sum $S=(1^1+2^2+3^3+4^4+5^5+6^6...+98^{98})$ is divided by $4$ then what is the remainder? 

I know that all the even terms I can ignore since $(2n)^{2n}=4^nn^{2n})$ which is divisible by $4$,but i dont know what to do next it. Also I know we can write each of them as $(99-98)^1+(99-97)^2+(99-96)^3...+(99-1)^{98}$.

In mod $4$, note that for any positive integer $m$,
$$(2m)^{2m}=(4m^2)^m\equiv 0$$$$(4m-1)^{4m-1}\equiv (-1)^{4m-1}\equiv -1$$$$(4m-3)^{4m-3}\equiv 1^{4m-3}\equiv 1$$
and that $97=4\cdot 25-3,\ 95=4\cdot 24-1$. 
Hence, we have
$$S\equiv 24\cdot (-1)+25\cdot 1\equiv 1.$$
