is it guaranteed that the last digit of $2 ^ n$ cycles through $2,4,8,6$

90 Views Asked by At

this question was raised over in stackoverflow.

Somebody wanted to know what the last digit was for $2^n$ with $n$ in range $1$ to $10^6$

An answer pointed out that the last digit always cycles $2,4,8,6$ so simply divide $n$ by $4$ . But is that certain, I mean it works for $n$ up to $8$ (simple calc) , but what about $n = 54256$

4

There are 4 best solutions below

0
On

Yes, it's a sure thing. The pattern continues forever.

For $n=54256$, since $54256 \equiv 0 \mod 4$, the last digit is $6$.

(Actually, you only need to look at the last two digits of $n$ because of the divisibility rules for $4$!)

1
On

When you multiply a natural number by 2, you start from the rightmost digit and double it. You write down the last digit of the product as the last digit of your final answer, and if necessary carry the 1 from the tens column over to the left.

Now consider by induction: $2^1$ ends with 2. Doubling it gets 4. Doubling again gives 8. Then 16 - you carry the 1, but forget about that because you only care about the last digit. Now when you double the 6 at the end of your previous product, you get 12 - carry the 1 over, but you only care about the 2 at the end of the 12. Now you can mentally ignore every digit except for the last one, and see that you're right back to where you started, so the last digit does indeed cycle through that sequence forever.

2
On

It is true. It will cycle through $2,4,8,6$.

For example, if $2^m = 10x + 6$(a number that ends with $6$), then $2^{m+1}=20x + 12 = (2x+1)10 + 2$, hence the next number ends with $2$.

You can perform similar trick with the other $3$ cases.

3
On

Yes, because the set $ \text {{ 2,4,8,6,2,4,8,6,2,....}}$ is closed under multiplication by $2$ mod $(10)$.

Thus it really does not matter how large $n$ is,$2^n$ always ends at one of these numbers.

Since the cycle $ \text {{ 2,4,8,6,....}}$ repeats with increasing powers of two , we see that the last digits indeed cycle through that set.