[Math] Find the remainder when $7^{7^{7}}$ is divided by 1000

elementary-number-theory

I need help with this problem please

Find the remainder when $7^{7^{7}}$ is divided by $1000$

My try follow

$1000=8×125$ , now

$7 \equiv -1 \;\bmod\; (8)$
$\to$ $7^{7^{7}} \equiv -1 \;\bmod\; (8)$ and

$7^{100}\equiv 1 \;\bmod\; (125)$

Any help to complete this solution?

Best Answer

Since $7^4=2\,401\equiv1\pmod{400}$ and since $7^3=343$, $7^7\equiv343\pmod{400}$. So, by Fermat-Euler, $7^{7^7}\equiv7^{343}\pmod{1\,000}$.

Since $7^4\equiv401\pmod{1\,000}$, $7^{20}=(7^4)^5\equiv1\pmod{1\,000}$. Therefore$$7^{343}=7^{340+3}\equiv7^3=343\pmod{1\,000}.$$