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.)

$$\phi(40)=16 \to 7^{16}\equiv 1$$mod 40 $$7^{16}\equiv 1 \\7^{13}7^3\equiv 1\\
343.7^{13}\equiv 1 \\
(320+23).7^{13}\equiv 1\\
23.7^{13}\equiv 1\\
23.7^{13}\equiv 1+40 \equiv 1+80\equiv 1+120\equiv 1+160\\
23.7^{13}\equiv 161 \\23.7^{13}\equiv 7(23)$$ divide by $23$  , $(23,40)=1 
$
so 
$$23.7^{13}\equiv 7(23) \to 7^{13}\equiv 7$$
