# How do I find the last digits of large numbers using modular arithmetic?

I know I have to consider things base 10 and use the multiplicative and additive properties of modular arithmetic. But I still am not sure how to do this.

For example: can someone help me with showing the methods of getting the last digit to these numbers?

1) $(3^5)^7$

2) $(7^5)^3$

3) $(11^{10})^6$

4) $(8^5)^4$

Thanks!

• The last digit of $n$ is $n\pmod {10}$. – lulu Oct 5 '16 at 21:16
• @Lulu how would you prove that? – arpf Feb 26 '17 at 19:29
• @AnaFonseca That's what $\pmod {10}$ means. To write it out, suppose your base-$10$ number was written as $N=\overline {d_nd_{n-1}\cdots d_1d_0}$. That means $N=\sum_{i=0}^n d_i\times 10^i$. We see at once that $10$ divides every term except, possilby, $d_0\times 10^0=d_0$. Thus $N\equiv d_0\pmod {10}$. – lulu Feb 26 '17 at 20:17

## 3 Answers

As $3$, for instance, is prime to $10$, we can apply Euler's theorem: $3^4\equiv 1\mod 10$, hence $$\bigl(3^5\bigr)^7=3^{35}\equiv3^{35\bmod4}\mod 10=3^3\equiv 7\mod 10.$$ As to $8$, which is not coprime to $10$, its powers modulo $10$ follow this pattern: $$\begin{array}{c|cccccc} n&1&2&3&4&5&\dots\\ \hline 8^n&8&4&2&6&8&\dots \end{array}$$ so $8^n\equiv 8^{n\bmod4}\mod 10$ if we agree to represent integers modulo $4$ by a number in $\{1,2,3,4\}$ instead of $\{0,1,2,3\}$. Thus $$\bigl(8^{5}\bigr)^4=8^{20}\equiv8^4\equiv 6.$$

To find the last digit, $d_0$, of a number $N$, you want: $d_0 = N \mod 10$. (I.e., $d_0$ is the remainder from dividing $N$ by 10.)

Now, to find the next-to-last digit of $N$, realize that it is the last digit of $${1 \over 10}(N - d_0)$$

• If the numbers are too large to calculate exactly, how can you use modulo techniques for this next-to-last? – Colin D Apr 4 '18 at 16:31

I'lll explain 4) as an example. So we have $(8^5)^4$ (mod10). So the goal is to either reduce 8 modulo 10, or arrange the powers to make the number more manageable. Since 8 is congruent to 8 mod 10, we will work with the exponents. So $(8^5)^4=(8^4)^5=(8^{2})^{2x5}=16^{2x5}=6^{2x5}$mod 10. Then $6^{2x5}=36^5=6^5$ mod 10. Finally, $6^5=46,656=6$ mod 10. And there is your last digit.

• I would have gone with $8 \equiv -2\pmod{10}$. Then $(8^5)^4 \equiv (-2^5)^4 \equiv (-32)^4 \equiv (-2)^4 \equiv 16 \equiv 6 \pmod{10}$. – B. Goddard Oct 6 '16 at 0:47
• @B.Goddard much easier to handle that way. – nEv3r Oct 6 '16 at 0:52