Divisibility by Four and Eight

Divisibility By Four

Divisibility Rule

Suppose we have an integer N. It could be written in the following form:

10^n * a_n + ... + 10 * a_1 + a_0

Since 100 is divisible by 4, all the parts with index n > 1 can be ignored.
But how to tell whether 10 * a_1 + a_0 is divisible?

The trick is to use the fact that 20 is also divisible by 4.
And any number that could be represented as 2n * 10 is divisible by 20.

Therefore, in order for the whole number to be divisible by 4, if the penultimate digit is even, the last digit must be divisible by 4 (so it has to be 0, 4 or 8).

And if the penultimate digit is odd, the last digit must be even and not divisible by 4 (so it’s either 2 or 6).

Obviously, if the last digit is odd, the whole number is not divisible by 4.

Proof

Part 1

2 * n * 10 + a = 20 * n + a

20 * n is divisible by 4 because 20 is divisible by 4.

A positive single-digit number a is divisible by 4 only if a is 0, 4 or 8. There are no other (positive) single-digit numbers divisible by 4.

Part 2

(2 * n + 1) * 10 + a = 20 * n + 10 + a = 20 * n + 8 + 2 + a

As we’ve already seen, 20 * n is divisible by 4.
8 is also divisible by 4. So we can omit this part, and what we are left with is:

2 + a = 4 + (a - 2)

In order for the whole number to be divisible by 4, we need a - 2 to be divisible by four.

A positive single-digit number a minus 2 is divisible by 4 only if a is 2 or 6.

Divisibility By Eight

Divisibility Rule

Same logic applies, with a few alterations.
1000 is divisible by 8, so we only have to consider this part:

100 * a_2 + 10 * a_1 + a_0

Interestingly, 20 * 10 is also divisible by 8.
Since we now have three digits to care about instead of two, things get a bit more complicated. But the idea is the same.

Again, the 2 * n * 100 number is divisible by 8, so we can omit this part.

  1. If the last digit is odd, obviously the original number is not divisible by 8.

  2. If the last digit is 8:
    and if the first digit of three-digit number is even,
    then the original number is divisible by 8 if the second digit is 0, 4 or 8.

    And if the first digit of three-digit number is odd,
    then the original number is divisible by 8 if the second digit is 2 or 6.

  3. If the last digit is 6:
    and if the first digit of three-digit number is even,
    then the original number is divisible by 8 if the second digit is 1, 5 or 9.

    And if the first digit of three-digit number is odd,
    then the original number is divisible by 8 if the second digit is 3 or 7.

  4. If the last digit is 4:
    and if the first digit of three-digit number is even,
    then the original number is divisible by 8 if the second digit is 2, or 6.

    And if the first digit of three-digit number is odd,
    then the original number is divisible by 8 if the second digit is 0, 4 or 8.

  5. If the last digit is 2:
    and if the first digit of three-digit number is even,
    then the original number is divisible by 8 if the second digit is 3 or 7.

    And if the first digit of three-digit number is odd,
    then the original number is divisible by 8 if the second digit is 1, 5 or 9.

  6. Finally, if the last digit is 0:
    and if the 3 digit-number divided by 10 is divisible by 4,
    then the original number is divisible by 8.

Proof

Proof is pretty much the same as in the case of divisibility by 4.
But let’s take a look at it anyway.

Last Digit 8

2 * n * 100 + 10 * a + 8 = 200 * n + 10 * a + 8 = 200 * n + (5 * 2) * a + 8

200 * n is divisible by 8 because 200 is.
8 is obviously divisible as well.

For 5 * 2 * a to be divisible by 8, 5 * a must be divisible by 4. For that to be true, a must be divisible by 4, since 8 = 2 * 4. So a can only be 0, 4 or 8 for the original number to be divisible.

(2 * n + 1) * 100 + 10 * a + 8 = 200 * n + 96 + 4 + (5 * 2) * a + 8

Again, we can ignore the 200 * n + 96 + 8 part which leaves us with:

4 + (5 * 2) * a = 2 * 2 + 5 * 2 * a = 2 * (2 + 5 * a)

Therefore, 2 + 5 * a must be divisible by 4 in order for the original number to be divisible by 8.

Which means that 5 * a must be an even number that is not divisible by 4. Which in turn means that a must be an even number as well. Since it is also a single-digit number, it only leaves us with 2 and 6.

This is the proof for the case #1. Notice its symmetry with the case #3.

Last Digit 6

Cases #2 and #4 are similar and have the same symmetry, but let’s review one of them anyway, #2 for example.

2 * n * 100 + 10 * a + 6 = 200 * n + 10*a + 6

Again, 200 is divisible and can be ignored.

10 * a + 6 = 5 * 2 * a + 2 * 3 = 2 * (5 * a + 3)

So 5 * a + 3 must be divisible by 4.

1
2
3
4
5 * a + 3 =
(4 + 1) * a + (4 - 1) =
4 * a + a + 4 - 1 =
4 * (a + 1) + a - 1

4 * (a + 1) is divisible by 4, and for a - 1 to be divisible, given that a is a positive single digit number, a must be 1, 5 or 9.

1
2
3
4
(2 * n + 1) * 100 + 10 * a + 6 =
200 * n + 96 + 4 + 10 * a + 6 =
200 * n + 96 + 10 + 10 * a =
200 * n + 96 + 10 * (a + 1)

Again, 200 and 96 can be omitted.

1
2
10 * (a + 1) =
5 * 2 * (a + 1)

Therefore, 5 * (a + 1) must be divisible by 4.
Let’s apply the same trick:

1
2
(4 + 1) * (a + 1) =
4 * (a + 1) + (a + 1)

4 * (a + 1) is obviously divisible by 4.

And in order for a + 1 to be divisible by 4, a must either be 3 or 7 (since it is a positive single digit number).

Same works for case #4.

Last Digit 0

Case #5 is a bit different though.
The corresponding numbers could be represented like this:

100 * n + 10 * a + 0

But we might as well represent it this way:

10 * a = 5 * 2 * a

For 5 * 2 * a to be divisible by 8, 5 * a must be divisible by 4.
And for that, a must be divisible by 4, since 5 is not.

Thus, if the last digit is 0 and the original number divided by 10 is divisible by 4, then the original number is divisible by 8.