Глосарій

Виберіть одне з ключових слів ліворуч ...

Divisibility and PrimesDivisibility Rules

Час читання: ~20 min

There are a few different rules that can make it surprisingly easy to check if a number is divisible by another. In this section we will have a look at some of them…

Divisibility by 2 and 5

Every number is divisible by 1. To determine if a number is divisible by 2, we simply have to check if it’s even: any number that ends in 0, 2, 4, 6, or 8 is divisible by 2.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30

To see if a number is divisible by 5, we similarly just have to check that its last digit is 0 or 5:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30

The reason why these rules for 2 and 5 are so simple has to do with our number system. The base of our number system is 10, which means that every digit in a number is worth 10 times as much as the next one to the right. If we take the number 6382 as an example,

6382
=6000=300=80=2

Now we can separate the last digit of a number from all its other digits:

abcd=abc × 10+d
6382=638 × 10+2

Both 2 and 5 are factors of 10, so they will abc × 10, no matter what the values of a, b and c are. Therefore we only have to check the last digit: if d is divisible by 2 then is also divisible by 2. If d is divisible by 5 then the whole number is divisible by 5.

The easiest is the divisibility rule for 10: we just need to check if the .

Divisibility by 4 and 8

Unfortunately 4 doesn’t divide 10, so we can’t just look at the last number – but 4 does divide 100, so we just have to slightly modify our rule from above. Now we write abcd = ab × 100 + cd. We know that 4 will always divide ab × 100, so we have to look at the last digits to check if a number is divisible by 4.

For example, 24 is divisible by 4 so 273524 divisible by 4, and 18 is not divisible by 4 so 194718 divisible by 4.

The divisibility rules for 8 get even more difficult, because 100 is not divisible by 8. Instead we have to go up to and look at the last digits of a number.

For example, 120 is divisible by 8 so 271120 is also divisible by 8.

Divisibility by 3 and 9

The divisibility rule for 3 is rather more difficult. 3 doesn’t divide 10, and it also doesn’t divide 100, or 1000, or any larger power of 10. Simply looking at the last few digits of a number isn’t going to work.

Instead we need to use the digit sum of a number, which is simply the sum of all its individual digits. For example, the digit sum of ${13×n+123} is ${digitSumString(123+13×n)} = ${digitSum(123+13×n)} and the digit sum of 3524 is .

1
2
3
3
4
5
6
6
7
8
9
9
10
11
12
3
13
14
15
6
16
17
18
9
19
20
21
3
22
23
24
6
25
26
27
9
28
29
30
3
31
32
33
6
34
35
36
9
37
38
39
12
40

Here we’ve highlighted all numbers which are multiples of three. You can see that their digit sums are always .

So to determine if any number is divisible by 3, you just have to calculate its digit sum, and check if the result is also divisible by 3.

Next, let’s look at multiples of 9:

9
9
18
9
27
9
36
9
45
9
54
9
63
9
72
9
81
9
90
9
99
18
108
9
117
9
126
9
135
9
144
9
153
9
162
9
171
9
180
9

It seems that all the numbers divisible by 9 have a digit sum which is divisible by 9. For example, the digit sum of 4752 is , so 4752 divisible by 9.

Of course, these curious patterns for numbers divisible by 3 and 9 must have some reason – and like before it has to do with our base 10 numbers system. As we saw, writing the number 6384 really means

6 × 1000 + 3 × 100 + 8 × 10 + 4.

We can split up each of these products into two parts:

6 × 999 + 6 + 3 × 99 + 3 + 8 × 9 + 8 + 4.

Of course, 9, 99, 999, and so on are always divisible by 3 (or by 9). All that remains is to check that what’s left over is also divisible by 3 (or 9):

6 + 3 + 8 + 4

This just happens to be the digit sum! So if the digit sum is a multiple of 3, and we know that everything else is a multiple of 3, then the result must also be a multiple of 3.

Divisibility by 6

We’ve still skipped number 6 – but we’ve already done all the hard work. Remember that 6 = 2 × 3.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40

To check if a number is divisible by 6 we just have to check that it is divisible by 2 divisible by 3. Note that this happens to work for 6, but certainly not for any number that is the product of two others. More on that later…

Archie