# The Last Digit of HUGE numbers

What is the last digit of $2016^{2016}$?

Such numbers of this type are impossible to work out on a calculator, and even difficult for your computer to even display on the screen! The number $2016^{2016}$ itself is 6,666 digits long! To give you an example of how huge such numbers are, the following number is 1000 digits long. Imagine it 6 times longer!

10000000000000000000000000000000000000000
0000000000000000000000000000000000000000
0000000000000000000000000000000000000000
0000000000000000000000000000000000000000
0000000000000000000000000000000000000000
0000000000000000000000000000000000000000
0000000000000000000000000000000000000000
0000000000000000000000000000000000000000
0000000000000000000000000000000000000000
0000000000000000000000000000000000000000
0000000000000000000000000000000000000000
0000000000000000000000000000000000000000
0000000000000000000000000000000000000000
0000000000000000000000000000000000000000
0000000000000000000000000000000000000000
0000000000000000000000000000000000000000
0000000000000000000000000000000000000000
0000000000000000000000000000000000000000
0000000000000000000000000000000000000000
0000000000000000000000000000000000000000
0000000000000000000000000000000000000000
0000000000000000000000000000000000000000
0000000000000000000000000000000000000000
0000000000000000000000000000000000000000
000000000000000

So really, the question is…

Can we find the last digit of a number, without having to work out what the entire number is?

#### YES we can!

To carry this out, we shall be using ideas from so called Modular Arithmetic. It essentially is the study of the standard mathematical operators such as $+ \text{ or } \times$ but in a restricted way. If this sounds exotic and mysterious, it really isn’t! Essentially, you do Modular Arithmetic everyday when you calculate the time.

Say that you currently have a meeting at 12pm and 4 hours from then, you have an appointment. What time is the appointment?

Clearly, it is 4pm. But what are we doing here?

$12+4 \equiv 4$

This is Modular Arithmetic! There is something iffy with what’s written above though… notice that we have replaced the standard $=$ with this funny looking symbol $\equiv$. The reason why this was done, is because we obviously know that $12+4=16$ but in this case, we are not doing standard addition we are carrying out modular arithmetic, which requires a new way of writing things to avoid confusion.

So what’s the idea here?

As we said before, this is similar to a clock. Why is it the case that when we think of 14:00, 20:00 and 23:00,  we translate those to 2,8 and 11 respectively?
If you’ve never known, then the next part is going to pretty cool. The reason why is because

$14-12=2$

$20-12=8$

$23-12=11$

But notice that for 24:00 (which we denote it as 00:00).

$24-12-12=0$

So it seems that the idea is to just remove as many 12s as you can until you obtain a number that is less than 12, which is similar to the idea of a remainder. In general, were we to have any number, say 50, we can continually remove ’12’ to obtain

$\begin{array}{rcl} 50-12&=&38\\38-12&=&26\\26-12&=&14\\14-12&=&2 \end{array}$

To simplify our world a bit, instead of writing

$50-12-12-12-12=2$

We shall simplify this to

$50 \equiv 2 (mod 12)$

Which translates to “2 is the remainder you get when you remove as many 12s as you can from the number 50”

How does this help us in solving our problem? Well, instead of thinking of a clock with 12 hours, we shall think of a clock with 10 hours.

This means that 10 becomes 0 and 15 becomes 5 in our modular arithmetic world, which is really just “Read forward in time off a funny clock”.

We iterate again why this is so:

$10-10 = 0$

$15-10 = 5$

or in our short form, $10 \equiv 0 (mod 10) \text{and} 15 \equiv 5 (mod 10)$. What this is doing is extracting the last digit of our number! The number 125214 may be written down as 12521 collection of 10s and a 4. In other words,

$125214 = (12521\times 10)+4$

Which means that on our funny clock, we would just read it as 4.

How does this help in figuring out what the last digit of $2016^{2016}$ is?

Well, it turns out that we can similarly define the same idea not only for $+$ but also for $\times$ as well!

$8^2=8\times 8 = 64 \equiv 4 (mod 10)$

It turns out there is a neat trick that you can do to save you A LOT of time when it comes to figuring out what the last digit of large numbers taken to powers.
That is, the last digit of a number $x^a$ is simply the last digit of $x$ to the power of $a$.

In terms of our problem, this means that $2016^{2016}$ has the same last digit as $6^{2016}$ since $2016\equiv 6 (mod10)$.

Great! This means that we only need to figure out the last digit of $6^{2016}$.

## …

How in the world do we do that?

Well, this isn’t really difficult. In fact, I’ll let you see why.

$\begin{array}{rcl}6^1=6 &\equiv& 6 (mod 10)\\6^2=36 &\equiv& 6 (mod 10)\\6^3=216 &\equiv& 6 (mod 10) \\6^4 =1296&\equiv& 6 (mod 10) \end{array}$

No matter how many times I multiply 6 by itself, I always get a remainder of 6 when I extract its remainder from continually remove 10s! This means that the last digit of $2016^{2016}$ is 6!

Or in our short hand $2016^{2016} \equiv 6 (mod 10)$

Such an enormously huge number has been defeated with just a handy way of thinking about clocks in a funny way! Stay tuned for the next few posts where I shall be tackling more and more techniques to find the last digit of more and more huge exotic numbers :)!

Follow this blog if you would like to read similar content, as well as Philosophy, Statistics and more Mathematics  :)!