<s>[INST] How can one calculate $342342^{1001}$ mod $5$? How can one calculate $342343^2$ mod $3$? I know that the answer is $1$.
And $342342^{1001}$ mod $5$. 
I know that
$
3^0 \mod 5 = 1 \\
3^1 \mod 5 = 3 \\
3^2 \mod 5 = 4 \\
3^3 \mod 5 = 2 \\\\
3^4 \mod 5 = 1 \\
3^5 \mod 5 = 3 \\
3^6 \mod 5 = 4 \\
$
So 1001 = 250 + 250 + 250 + 250 + 1, which is why the answer is also 1?
 [/INST] $$342342^{1001} \equiv2^{1001} \space \bmod5$$
$$2^{1001}=2 \times (2^4)^{250}\equiv2\times1^{250}\bmod 5=2$$
Case $342343^2 \bmod 3$ is even simpler. You can easily prove that $a^2\equiv 0 \bmod 3$ iff $a\equiv0\bmod3$. In all other cases $a^2\equiv 1 \bmod3$.
Number 342343 is not divisible by 3 so the result must be 1.
</s>