HI, I have not checked every detail calculations of yours. But thanks for sharing it.

Here is another way :

$\begin{align*} &=\left [ 4^{40} + 6^{40} \right ] \mod 25 \\ &=\left [ \left ( 5-1 \right )^{40} + \left ( 5+1 \right )^{40} \right ] \mod 5^2 \\ &=\left [ \left \{ \binom{40}{0} \cdot 5^0 \cdot (-1)^{40} + \binom{40}{1} \cdot 5^1 \cdot (-1)^{39} \right \} + \left \{ \binom{40}{0} \cdot 5^0 \cdot (+1)^{40} + \binom{40}{1} \cdot 5^1 \cdot (+1)^{39} \right \} \right ] \mod 25 \\ &= \left [ 1 - 200 + 1 + 200 \right ] \mod 25 \\ &=2 \end{align*}$

Here is another way :

$\begin{align*} &=\left [ 4^{40} + 6^{40} \right ] \mod 25 \\ &=\left [ \left ( 5-1 \right )^{40} + \left ( 5+1 \right )^{40} \right ] \mod 5^2 \\ &=\left [ \left \{ \binom{40}{0} \cdot 5^0 \cdot (-1)^{40} + \binom{40}{1} \cdot 5^1 \cdot (-1)^{39} \right \} + \left \{ \binom{40}{0} \cdot 5^0 \cdot (+1)^{40} + \binom{40}{1} \cdot 5^1 \cdot (+1)^{39} \right \} \right ] \mod 25 \\ &= \left [ 1 - 200 + 1 + 200 \right ] \mod 25 \\ &=2 \end{align*}$