Computing $7^{13} \mod 40$ I wanted to compute $7^{13} \mod 40$. I showed that 
$$7^{13} \equiv 2^{13} \equiv 2 \mod 5$$
and
$$7^{13} \equiv (-1)^{13} \equiv -1 \mod 8$$.
Therefore, I have that $7^{13} - 2$ is a multiple of $5$, whereas $7^{13} +1$ is a multiple of $8$. I wanted to make both equal, so I solved $-2 + 5k =  + 8n$ for natural numbers $n,k$ and found that $n = 9, k = 15$ gave a solution (just tried to make $3 + 8n$ a multiple of $5$. Therefore, I have that 
$$7^{13} \equiv -73 \equiv 7 \mod 40.$$
Is this correct? Moreover, is there an easier way? (I also tried to used the Euler totient function, but $\phi(40) = 16$, so $13 \equiv -3 \mod 16$, but I did not know how to proceed with this.)

You don't necessarily have to use the fact $40=8\times 5$ (but if you do, look up "Chinese remainder theorem".)

Otherwise, you know that 
$$7^2\equiv 49\equiv 9\pmod{40}.$$
So
$$7^3\equiv 63\equiv 23\pmod{40},$$
so
$$7^4\equiv 161\equiv 1\pmod{40}.$$
Then
$$7^{13}\equiv 7^{4\times 3}\times 7\equiv 1\times 7\equiv 7\pmod{40}.$$
