Divisibility Rules

Contents

In my post on The Divisible Numbers Challenge, I mentioned a trick for determining in your head whether a number is divisible by 4. A friend told me that that note was silly because everybody learns that stuff in primary school, which surprised me. While I did learn about it in primary school, for some reason, I never realised that it’s probably common knowledge. Of course, I was aware that some things are taught pretty much universally. For example, I assume almost everybody knows about long division, even if most people probably have it grow rusty from disuse. I guess I just always assumed that divisibility rules are kind of a niche topic that never comes up. It seemed like one of those factoids 1 that you can bring up to surprise people. But even still, maybe it is as uncommon as I believed, or maybe a reader finds themselves among the lucky 10,000 because their school didn’t cover it, they missed it, or for some other reason I could never even guess at..

But there’s a reason most people’s long division is rusty. Am I going to say something along the lines of you won’t always have a calculator in your pocket?? People have smartphones nowadays and can do actual precise division as fast as they can type. And hasn’t everything that can be said about this topic already been said by so many people? What’s the point of learning divisibility rules?
I’m actually not sure if I’ve got a good answer for most people. If you’re maths-curious, I think this blog post is for you. It’s a great introduction to some algebra topics that you don’t usually come across in high school. If you’re considering studying maths or even something just tangentially related to maths, maybe this can help nudge you in the right direction, whether you actually like it or not. Moreover, you can always apply these rules whenever you see a number. Does it really need to be extremely useful? Or maybe you’re looking to join some tool-less maths competition. In that case, Godspeed.

To set some ground rules, we’re only looking at integers, more specifically the natural numbers (positive numbers), although it’s fairly simple to extend to the whole integer set. We say a number divides another when the division results in no remainder. My maths is rusty, so I will focus on intuition over rigorous formalism. Luckily, I believe most of it should be understandable with a high-school level of maths. Also note, we’re staying in base 10 because that’s what I usually use, even if a base 12 system has its clear advantages. I will assume that most readers will be used to working in base 10 as well.

I’ll tackle the numbers to divide by in roughly increasing order of complexity.

Divisibility by 1#

Okay, maybe I wasn’t quite clear about my ground rules. I thought it’s clear that you can divide any integer number by 11 without a remainder. If the number exists, it is divisible by 11.

Divisibility by 10#

Uhm, well, you know, if a number ends in 00, it’s divisible by 1010. Just look at its last digit. When are we getting to anything actually interesting?

Divisibility by 5#

A number is divisible by 55 if its last digit is either 55 or 00. Any higher digits are a multiple of 1010 and thus divisible by 55. But seriously, is this entire post like this?

Divisibility by 2#

We’re still in easy territory here. A number is divisible by 22 if its last digit is divisible by 22. That is, 5454 is divisible by 22 while 4545 is not.

Divisibility by 4#

A number is divisible by 44 if its last 2 digits are divisible by 44. Any higher digits are necessarily a multiple of 100100, and we know that 100100 divides by 44. You’re still going to have to figure out yourself if 9494 divides by 44. It might help to just divide by 22 twice. Maybe it’s easier to tell whether 94/2=4794/2=47 divides by 22 if a decomposition into 94=80+1494=80+14 isn’t natural to you.

Divisibility by 8#

A number is divisible by 8 if its last 3 digits are divisible by 88. But wait, there’s a pattern! I picked up on this when I first heard about it, but today I actually want to know more. Does this pattern hold? Sure enough, a number is divisible by 1616 if its last 4 digits are divisible by 1616, although maybe that’s not as useful of a rule of thumb to compute in your head any more. Does this generalise?

Yes! In fact, the proof is fairly simple. We can prove for any nn, that 2n2^n divides 10n10^n. Maybe it already becomes clearer when put like this. Specifically, it is 2n⋅5n=(2⋅5)n=10n2^n\cdot 5^n=(2\cdot 5)^n=10^n. This also allows us to see that 125=53125=5^3 divides 10001000, but I’ll leave mental application as an exercise to the reader.

Now we know that powers of 22 always divide powers of 1010, but dividing a 3-digit number in your head by 88 is still hard. Again, maybe you can just divide by 22 thrice. Or maybe, you still need to pull out your calculator after all. On the other hand, I can’t remember a time in my life where I needed to check if a number divides by 8 in my head. Then again, I also have a very bad memory for stuff like this, so for all I know, I might be doing it daily.

Divisibility by 3 and 9#

To check if a number is divisible by 33, it is useful to check if its digit sum is divisible by 33. To compute the digit sum, we just look at each digit and add its value to the others. So for 4545, the sum is 4+5=94+5=9. Because 99 is divisible by 33, we can conclude that 4545 is divisible by 33. That may not be that useful in this example, but say instead you’re looking at 12345678901234567890, a common number we may see in the wild. Let’s say somebody has a gun to your head and asks you whether it divides by 33. Well, lucky you, instead of pulling out pen and paper to do a long division and check the remainder, you can see that the sum of the numbers from 11 to 99is 9⋅102=45\frac {9\cdot 10}{2}=45 and is thus divisible by 33. Reading this blog may have just saved your life!

But why does this work? Feel free to take a moment to think about it yourself. It’s surprisingly simple once you’ve hit on the right way to think about the problem, but don’t worry if you don’t get it this time. There will be more opportunities.

…

Let’s say we’ve got the number abcabc, where each letter represents a digit. For example, for the number 123123 we’d have a=1a=1, b=2b=2, and c=3c=3. In other words, we have 100a+10b+c100a+10b+c. We can pull out some numbers that we know divide by 99 (and by extension 33).

100a+10b+c=99a+9b+a+b+c 100a+10b+c=99a+9b+a+b+c

99a99a will always divide by 99, so if we subtract it, the remainder will divide by 99 exactly if the whole sum divides by 99. This is similar to how long division works if you think about it: subtracting increasingly small multiples of the divisor. In other words, the 100a+10b+c=100a+10b+c= will divide by 33 or 99 exactly if a+b+ca+b+c does. And with that, we’ve basically arrived at the digit sum. We can of course extend this pattern: the next digit would be (1+999)d(1+999)d, and so forth. The principle applies to any number of digits.

Divisibility by 6#

Number 66 is on the one hand boring because it doesn’t introduce any crazy new rules and on the other hand interesting because it shows us a pattern of relationships between different rules. Such is the case for any number that factorises into a set of unique prime numbers. To check if a number divides by 66, check if it divides both by 22 and 33. It will necessarily divide by 66 only if it divides by both.

Divisibility by 7#

This is the part we’ve all been waiting for. (We have, right? Well, I was waiting for it at least.) This is also the first time I learnt these rules at all, because apparently “the rules for 7 are too complicated”, according to my primary school teacher. Well, Mrs. Doe (not the actual name), I’ll show you, only almost 2 decades later!

We’ll go over two different rules and the reasoning behind them. The first is a general solution strategy, but it becomes cumbersome for large values. The second one can easily reduce an arbitrarily large number to a 3-digit equivalent, but it’s still hard to divide 3-digit numbers by 7 in your head.

General strategy#

Let’s get started with the general strategy. The idea is to add the last digit to the rest 5 times. That is, for a number with digits abab, instead check if a+5ba+5b is divisible by 77. Note that aa may have multiple digits. (fancypants mathematicians might instead write γb\gamma b or something, but I don’t want to confuse. I admit this is differently confusing.)

Let’s look at an example. Consider the number 14491449. We add the 99 to the rest 5 times: 144+45=189144+45=189. Repeat: 18+45=6318+45=63. We’re lazy, repeat: 6+15=216+15=21. REPEAT: 2+5=72+5=7. OK, I’m satisfied with that. It seems to be working, but why? Again, feel free to see if you can find the reason yourself. It’s a bit more complicated than what we looked at for 99, but we apply some very similar ideas.

Consider again how we wrote the digits above as abab. We can again write the number as 10a+b10a+b like we did for division by 99. Similarly, we can subtract 77 from the left: 3a+b3a+b. We say that this is divisible by 77 exactly if a+5ba+5b is. In fact, I’m going to make an even stronger claim and say that the remainder of both divided by 77 is the same. We write this as 3a+b≡7a+5b3a+b\equiv_7 a+5b, which means they share an “equivalence class”, or we just say they are equivalent modulo 77. Basically, we’re in a weird place where only the remainder of division by 77 matters. It is 8≡71≡7−68\equiv_7 1\equiv_7 -6, and the world is strange. Maybe you’ve heard of pp-adic numbers or a quotient ring before. If I remember my first year of uni correctly, that’s the construct we’re talking about here. Don’t be worried if those terms make no sense to you, we will cover what we need.

Let’s go back to our numbers. We want to check if the remainder is 00, or in other words, if 3a+b3a+b is in the same class as 00:

3a+b≡70. 3a+b\equiv_7 0.

We can do some transformations we’re used to from normal equations:

3a≡7−b 3a\equiv_7 -b

Now we want to divide both sides by 3. But how do we do that when we’re working on integers? What if bb is like 22 and doesn’t cleanly divide by 33? We’re going to have to familiarise ourselves with a new concept in quotient ring: division works differently here. Instead of dividing by a number, we have to find the element to multiply with to get 11. Or in other words, given a number xx, we want to find a number yy with x⋅y≡71x\cdot y\equiv_7 1. We also say that y=x−1y=x^{-1}. But isn’t this just division with extra steps? How can we find an element to multiply with to get 11 without having the element be like 1/x1/x? Aren’t we only working on integers? Remember that we’re in a quotient ring. In the case of 33, let’s just look at all the options.

Counter-pieceProduct≡7\equiv_7
3⋅13\cdot 13333
3⋅23\cdot 26666
3⋅33\cdot 39922
3⋅43\cdot 4121255
3⋅53\cdot 5151511
3⋅63\cdot 6181844
3⋅73\cdot 7212100

We can see that 55 is the only element that results in 11. In fact, it is a property of quotient rings that are based on prime numbers that such an element must always exist, and this fact is often used in Cryptography like RSA and others. And if we look at some examples: 5⋅6=305\cdot 6 = 30 and 30≡7230\equiv_7 2 . This seems to be working. Feel free to look at some other examples, but you can think of it like the factor 33 in whatever number we’re dividing being instead set to a multiple of 77, which is equivalent to a factor of 11.

But okay, so we know that

a≡7−5b. a\equiv_7 -5b.

Or in other words, 10a+b10a+b is divisible by 77 if and only if a+5ba+5b is. At this point, can you tell why a−2ba-2b might do the same trick?

Fast reduce#

The strategy above is nice and simple, but if you’ve got 10 digits, you’re going to be at it for a while. We want something faster. Well, I’ve got something faster. Group the number into groups of 3 digits starting from the right. Then form an alternating sum.

Doesn’t make sense? Let’s look at an example. Consider the number 12,345,67812,345,678. Then just do an alternating sum on groups of 3 like this: 678−345+012=345678-345+012=345. Just wrap up with the strategy from above: 34+25=5934+25=59 – not divisible.

Maybe you’re already getting an idea of how this works. Feel free to take a shot yourself.

…

…

Okay, we start by putting it into a general form again. Let cbacba be the number with each letter representing a group of 3 digits. Then we can also write the number as a+1,000b+1,000,000ca+1,000b+1,000,000c, or 100a+103b+106c10^0a+10^3b+10^6c. Like before, we subtract 7n7^n from each expression: 30a+33b+36c3^0a+3^3b+3^6c. If we now look at 333^3 inside our quotient ring, we have

33≡727≡728−1≡7−1. 3^3\equiv_7 27\equiv_7 28-1\equiv_7 -1.

So multiplying with 333^3 is equivalent to multiplying with −1-1! Naturally, multiplying with 363^6 is equivalent to multiplying with (−1)2=1(-1)^2=1. This means that 100a+103b+106c10^0a+10^3b+10^6c is divisible by 77 if and only if 1a−1b+1c1a-1b+1c is divisible by 77. Of course, we can extend this pattern to an arbitrary number of digits as well.

With that, we understand this strategy satisfactorily. Unfortunately, you’re usually left with a 3-digit number, but together with the other strategy, you’re still in a good spot.

Closing Thoughts#

As you can see, most of these rules aren’t actually very complicated once you understand the trick. I guess in hindsight that makes sense. You wouldn’t teach something monstrously complicated in primary school, even if we kept to a simple level.

We’ve only looked at strategies to check division with numbers up to 10, but we can take this up to any number we want. Wikipedia lists rules for numbers up to 30. While writing this post, I only saw the large table there. Turns out, I now see they have an extensive section describing different more efficient algorithms for divisibility by 77 than described here, although they seem harder to remember. If you ever intend to take part in a mathematics competition without a calculator, or if you just want to explore these concepts more, I recommend you check it out. This post should give you a good foundation to understand the concepts described.

Of course, you can also just see for yourself if you can find similar rules for larger numbers. Some numbers like 1212 or 1515 will be simple (remember 66). Other numbers, such as prime numbers like 13, will be harder. Either way, you now have the tools needed to find them yourselves. Or maybe you want to see if you can find a better algorithm for dividing by 77? Know yourself out! On the other hand, given how often you check if a number is divisible by 88, how much use are you going to get from being able to tell if a number divides by 1717? Not that that should stop you if you purely enjoy the maths of it. Ever thought about getting a degree in the field? For similar or maths related topics, you may enjoy the YouTube channels Numberphile, Stand-up Maths, 3Blue1Brown, and many more. I’m sorry that I don’t have any text-based further readings, but I only follow maths very casually on the side. Either way, numbers can be fun, and I hope you can appreciate them like I do, or maybe even more.


  1. “Factoid” in the “little known fact” sense, not as in “sounds like a fact but actually untrue” ↩︎

Page history (6 revisions)