2

If it's $2/3$ digits I could easily do that. But when I'm using Euler theorem, I still have to compute $3^{34567} \mod 100000$, which is still hard. Thank you in advance!

user577215664
  • 40,625

1 Answers1

1

It happens that $3$ has order $8\bmod 2^5=32$, so $$3^{1234567}\equiv 3^{1234567\bmod 8}=3^7\mod 2^5.$$

As to the congruence class $\bmod 5^5=3125$, we have $\varphi(5^5)=4\cdot 5^4=2500$, so $$3^{1234567}\equiv 3^{1234567\bmod 2500}=3^{2067}\mod 5^5.$$ This requires $11$ squarings and $3$ multiplications mod. $3125$ by the fast exponentiation algorithm.

Once you have the powers mod $32$ and mod $3125$, you can readily deduce the power mod $100{,}000$ by the explicit Chinese remainder theorem.

Bernard
  • 175,478