<s>[INST] 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}$.
 [/INST] $$S=1^1+2^2+3^3+4^4+5^5+6^6+7^7+...97^{97}+98^{98}\equiv \\S\equiv1^1+0+3^3+0+5^5+0+7^7+...+97^{97}+0\\\equiv1^1+3^3+5^5+7^7+...+97^{97}\\\equiv1^1+0+3^3+0+5^5+0+7^7+...+97^{97}+0\\\equiv1^1+3^3+5^5+7^7+...+97^{97}\equiv\\S\equiv1+(4k-1)^3+(4k+1)^5+(4k-1)^7+(4k+1)^9+(4k-1)^{11}...+(4k+1)^{97}\\\equiv1+(-1)^3+1^5+(-1)^7+...+(-1)^{97}\\(1,3,5,..97)=49 ,term\\so\\\equiv1+(-1+1)+(-1+1)+....=1
$$
</s>