[Math] Last digits number theory. $7^{9999}$

elementary-number-theory

i have looked at/practiced several methods for solving ex: $7^{9999}$. i have looked at techniques using a)modulas/congruence b) binomial theorem c) totient/congruence d) cyclicity.

my actual desire would be a start to finish approach using totient/congruence. i have figured out how to work the individual steps but not how to combine them and in what order to be able to solve any "end digits" questions.

Best Answer

Note:

$7^4$ ends in $1$

So, $7^8$, $7^{12}$, $7^{16}$ all end in $1$.

So, $7^{9996}$ ends in $1$. And $7^3$ ends in $3$. So, the answer is $3$

I have used the fact that $$ \phi(10) = 4 $$ where $\phi$ is the totient function.


Note: Added in response to OP's comment

If we want the last two digits, we note that $\phi(1000)=400$. So $$ 9999 = 9600 + 399$$ So $$ 7^{9999} \equiv 7^{399} \mod 1000 $$ Since $399$ is 1 less than $400$ we can calculate the answer easily. I will show both the long way and the short way.

Long way which works for any power (not all calculations shown):

We divide by two each time to get $$ 399 = 199+200 \\ 199= 99 + 100 \\ 88= 49 + 50 \\ 49= 24 + 25\\ 25 = 12 + 13 \\ 13 = 6 + 7 \\ 7 = 3+ 4\\ 3 = 1 +2 $$ Now (all mod 1000) $$ 7^1 = 7,~~~ 7^2 = 49\\ 7^3 = 7 \cdot 49 = 343, ~~~7^4 = 49 \cdot 49 = 401\\ 7^6 = 343 \times 343 = 649~~~ 7^7 = 343 \cdot 401 = 543 $$ and so on.

You can also find $7^{-1} \mod 1000$ as $143$. So the last 3 digits are 143

Related Question