1

Trying to find the easiest and most general method in finding last $n$ digits of a number. I know the trick lies in finding the remainder when the number is divided by $10^n$ but still not able to perform the rest of the steps to reach the answer

J. W. Tanner
  • 60,406

3 Answers3

2

Repeated squaring:

$$7^4 = 2401 \mod 10000$$ $$7^8 = 2401^2\equiv 4801 \mod 10000$$ $$7^{16}\equiv 4801^2\equiv 9601 \mod 10000$$ $$7^{32}\equiv 9201 \mod 10000$$ $$7^{64}\equiv 8401 \mod 10000$$ $$7^{128}\equiv 6801\mod 10000$$

Note: $2401^2=(2400+1)^2=2400^2+4800+1\equiv4801$, $4801^2\equiv4800^2+9600+1\equiv9601$,

$9601^2\equiv9600^2+2\times9600+1\equiv9200,$ etc.

J. W. Tanner
  • 60,406
1

$7^{128}\equiv(1-50)^{64}\equiv1-64\cdot50+\binom{64}250^2-\binom{64}350^3+\cdots+50^{64}$

$\equiv1-64\cdot50\pmod{10^4}$

as $10^4$ divides $50^n,n\ge4,$

and $10^4\mid\binom{64}250^2\iff\dfrac{10^4}{50^2}\mid\binom{64}2$

and similarly $10^4$ divides $\binom{64}350^3$

J. W. Tanner
  • 60,406
0

Below I show that the method in JWT's answer is also essentially Binomial Theorem based.

$\begin{align} 7^{\large 2}\ &= -1 + 50 \\[.3em] \Rightarrow\ \ \ \ \ \ \ 7^{\large 4}\ &=\ \ \ 1 + 24\cdot100\ \, (=\, 1 -2(50)+ 2500\ \ \rm by\ squaring\ above)\\[.3em] \Rightarrow\ (7^{\large 4})^{\large 32} &\equiv \ \ \ 1 + \color{#0a0}{32\cdot 24}\cdot 100\!\!\pmod{\!100^{\large 2}}\ \ \rm by\ Binomial\ Theorem\\[.3em] &\equiv\ \ \ 1\ \, +\, \ \color{#c00}{68}\,\ \cdot\,\ 100\ \ \ {\rm by}\ \ \color{#0a0}4\underbrace{(\color{#0a0}{8\cdot 24}\bmod 25)}_{\large 8\,(-1)\ \,\equiv\,\ \color{#c00}{17}\ \ \ \ \ \ \ } = \color{#c00}{4(17)} \end{align}$

Bill Dubuque
  • 272,048
  • We used $\large \ \begin{align} 100\cdot \color{#0a0}{4n}\bmod 100^{\large 2} &=\ 100\cdot\color{#0a0}4(\color{#0a0}n\bmod 25)\ ab\bmod ac\ \ \ \ &=\ \ \ \ \ \ \ \ \ a\ (b,\bmod c)\end{align} $ = mod Distributive Law $\ \ $ – Bill Dubuque May 10 '19 at 00:51