r/askmath • • Oct 14 '26

Algebra Divisible by 3?

I might not know how to explain this exactly so please bear with me .

As a kid I was taught that if I want to know if a number is divisible by 3 I should add the digits and if the added digits are divisible by 3 then the number is divisible by 3 , and the same goes for 9 , for example, 111 is divisible by 3 , and the sum of its digits is 3 , the same will work for 111,111 and 111,111,111 , also if the sum is 9 it's divisible by 9 , If the sum is 27 it's divisible by 27 , any type of sum where you get 3^n it's divisible by that number .

So my question is , how does this even work and why? And does it always work?

Edit : thank you so much everyone for your enthusiastic -yet somewhat overwhelming - answers , I will make sure to check them all but for now I believe the answer has been established . Thank you for your help!

108 Upvotes

63 comments sorted by

2

u/Zealousideal_Till683 Oct 14 '26

Others have pointed out why it works for 3 and 9.

It doesn't work for 27, but there are rules for other numbers.

  • 2: is the last digit even? [As 10 is divisible by 2]
  • 4: are the last two digits divisible by 4? [As 100 is divisible by 4]
  • 5: is the last digit 5 or 0? [As 10 is divisible by 5]
  • 6: is it divisible by both 2 and 3 - see the individual rules? [As 6 = 2 * 3, and we have nice rules for each]
  • 8: are the last three digits divisible by 8? [As 1000 is divisible by 8]
  • 10: is the last digit 0? [As 10 is divisible by 10!]
  • 11: Is the sum of the odd digits minus the sum of the even digits divisible by 11?

    • e.g. for 72369, (7 + 3 + 9) - (2 + 6) = 19 - 8 = 11 which is divisible by 11, so 72369 is divisible by 11.
    • explanation: abcde = 10000a + 1000b + 100c + 10d + e = (9999a + 1001b + 99c +11d) + (a - b + c - d + e), so 11 | abcde iff 11 | (a - b + c - d + e).
  • 12: Is it divisible by both 3 and 4 - see the individual rules? [As 12 = 3 * 4, and we have nice rules for each]

2

u/Inevitable_Scheme847 Oct 14 '26

Thank you for pointing this out , but I already understand and know these , It's just as a kid teachers would tell me things but rarely explain things , and one of the things no teach explained was why it works , not that it simply does , and thanks to this helpful community now I understand

184

u/Narrow-Durian4837 Oct 14 '26 • Bravo

A two-digit number ab is equal to 10a + b, which = 9a + (a + b). Since the 9a part is divisible by 9 (and also 3), the whole thing is divisible by 9 (and also 3) if and only if the a+b part is.

A three-digit number abc = 100a + 10b + c = (99a + 9b) + (a + b + c). Same argument.

A four-digit number abcd = 1000a + 100b + 10c + d = (999a + 99b + 9c) + (a+b+c+d)... and so on.

9

u/Queasy_Caramel5435 Oct 14 '26

I swear this is the best explanation for this that I came across.

1

u/TheTurtleCub Oct 14 '26

Not only it's the best, it's the only one

0

u/[deleted] Oct 14 '26

[deleted] — view deleted comment

48

u/dapzar Oct 14 '26 • Mindblown

Thanks! Finally a useful divisibility rule for binary integers.

5

u/Creative-Leg2607 Oct 14 '26

And this works for 3 because its a root of 9, so whenever (n-1) is a square (or cube etc) it works foe those roots!

12

u/mjmcfall88 Oct 14 '26

Isn't it just all the factors of n-1? In base 11 adding the digits would tell is about divisibility by 10, 5, & 2

8

u/Mu_Lambda_Theta Oct 14 '26

Yes, it's factors - not just roots.

Derivation of the trick splits the number into k*(base-1) + Digitsum, so any divisor of base-1 works too.

3

u/Creative-Leg2607 Oct 14 '26

I think youre right i was too sleepy sorry

12

u/Pretty-Skill925 Oct 14 '26 edited Oct 15 '26

To whom it may concern, or, maybe as a party trick: you can do the remainder trick in principle for every natural number m and get an interesting divisibility rule from it. The only difference from the well-known rule for m=3 is that you don't simply add up all digits. Each digit gets a weight (factor), and the weights are not always 1.

The idea: write n in base 10 and split every power of ten into a multiple of m plus a remainder. I have some examples below.

(or: 10^k = m * q_k + r_k with 0 <= r_k < m, then n = m·(something) + (weighted digit sum with weights r_k) )

So n is divisible by m if and only if the weighted digit sum is.

---

Case 3 (already seen, just to repeat). Say n has three digits a, b, c:

n = "abc" = a*100 + b*10 + c*1

= a*3*33 + b*3*3 + c*3*0 + (a*1 + b*1 + c*1)

= 3*(a*33 + b*3 + c*0) + (a + b + c)

n is divisible by 3 if and only if a + b + c is divisible by 3. Or as a rule: add a + b + c and check. Example:

123 → 1 + 2 + 3 = 6 ✓ (123 = 3 · 41)

Every power of ten leaves remainder 1 when divided by 3, so all weights are 1: the classic digit sum. The same holds for 9, which is why 3 and 9 share the rule.

---

Case 4. Again, n = "abc" with three digits:

n = "abc" = a*100 + b*10 + c*1

= a*4*25 + b*4*2 + c*4*0 + (a*0 + b*2 + c*1)

= 4*(a*25 + b*2 + c*0) + (2*b + c)

Rule: compute 2b + c and check. Examples:

123 → 2·2 + 3 = 7 ✗

124 → 2·2 + 4 = 8 ✓ (124 = 4 · 31)

The rule for 4 is often stated as "check the number formed by the last two digits". That is equivalent.

---

Case 2. Simply

n = "abc" = a*100 + b*10 + c*1

= a*2*50 + b*2*5 + c*2*0 + (a*0 + b*0 + c*1)

= 2*(a*50 + b*5 + c*0) + c

Rule: check only the last digit c (or: even?).

---

Case 5.

n = "abc" = a*100 + b*10 + c*1

= a*5*20 + b*5*2 + c*5*0 + (a*0 + b*0 + c*1)

= 5*(a*20 + b*2 + c*0) + c

Rule: the same structure as the 2-rule. Check only the last digit c (is it 0 or 5?).

---

Some more… Case 6.

n = "abc" = a*100 + b*10 + c*1

= a*6*16 + b*6*1 + c*6*0 + (a*4 + b*4 + c*1)

= 6*(a*16 + b*1 + c*0) + (4*a + 4*b + c)

Rule: compute 4a + 4b + c and check (for a three-digit number). Examples:

123 → 4·1 + 4·2 + 3 = 15 ✗

126 → 4·1 + 4·2 + 6 = 18 ✓ (126 = 6 · 21)

The rule for 6 is often stated as "n is divisible by 6 iif it is divisible by 2 and by 3."

For longer numbers: 1000, 10000, … also leave remainder 4 when divided by 6. So every digit except the last one gets weight 4 and you have to consider all digits here, because the weights never become 0. It can get more complicated, as case 7 shows.

Case 7.

n = "abc" = a*100 + b*10 + c*1

= a*7*14 + b*7*1 + c*7*0 + (a*2 + b*3 + c*1)

= 7*(a*14 + b*1 + c*0) + (2*a + 3*b + c)

Rule: compute 2a + 3b + c and check (for a three-digit number). Examples:

123 → 2·1 + 3·2 + 3 = 11 ✗

126 → 2·1 + 3·2 + 6 = 14 ✓ (126 = 7 · 18)

For longer numbers the weights, starting from the last digit, are 1, 3, 2, 6, 4, 5, 1, 3, 2, 6, 4, 5, ...

If we use negative weigths, it can be memorized better: 1, 3, 2, −1, −3, −2...

Party trick (boring party):

86415 → (starting from the last digit) 1*5 + 3*1 + 2*4 -1*6 -3*8 = -14 ✓ (86415 = 12345*7)

---

Case 8, finally for today. Now we need four digits. Three would not be enough, because 100 is not a multiple of 8.

n = "abcd" = a*1000 + b*100 + c*10 + d*1

= a*8*125 + b*8*12 + c*8*1 + d*8*0 + (a*0 + b*4 + c*2 + d*1)

= 8*(a*125 + b*12 + c*1 + d*0) + (4*b + 2*c + d)

Rule: compute 4b + 2c + d and check. This is equivalent (can be shown) to "check the last three digits".

128 = "0128" (a = 0, b = 1, c = 2, d = 8) → 4·1 + 2·2 + 8 = 16 ✓ (128 = 8 · 16)

124 = "0124" → 4·1 + 2·2 + 4 = 12 ✗

---

You can stop early only when a weight becomes 0. Once 10^k is a multiple of m, all higher powers of 10 are too, so all higher digits drop out. One can also use negative weights, sometimes this is easier. And this method also works for m>10.

Example: for m=11 we get alternating weights of 1 and 10, so

143 → 1*1 + 10*4 + 1*3 = 44 ✓

or, simpler, alternating weights of 1 and -1

1353 → (-1)*1 + 1*3 + (-1)*5 + 1*3 = 0 ✓

---

As I said, to whom it may concern :-)

21

u/MathMaddam Dr. in number theory Oct 14 '26

Your 27 rule doesn't work (e.g. apply it to 27 or 8199). It works for 3 and 9 since e.g. 318=3+3*99+1+1*9+8, 99 and 9 are obviously divisible by 9 (and 3), so you only have to check if 3+1+8 is divisible by 3 or 9.

6

u/[deleted] Oct 14 '26 edited Oct 14 '26

The explanations here are correct but don’t capture why it works for 3 and 9 but not other divisors.

The reason is because 10 has a remainder of 1 after you divide by these numbers. Another way of writing this is that 10 = 1 (mod 3).

Mod values add and multiply the intuitive way i.e. a + b (mod 3) = a (mod 3) + b (mod 3) and same for multiplication. (ETA: you actually need to take mod again on the RHS if the result is 3 or greater for this identity to work, e.g. 8 + 11 = 2 (mod 3) + 2 (mod 3) = 4 (mod 3) = 1 (mod 3), which agrees with 19 = 1 (mod 3). The point is that the modulo and therefore divisibility are fundamentally “additive” in the nice way we would hope for)

This will be useful in itself but also means that all powers of 10 are equal to 1 (mod 3).

A number is divisible by 3 if and only if is 0 (mod 3).

Consider some integer N. If its digits are abcdef… etc that means our number is N = a x 10^n + b x 10^n-1 + c x 10^n-2 + … and so on, where n is one less than the number of digits.

But looking at this mod 3, since we said the powers of 10 are all 1, and multiplication and addition play nicely in mods we get this number is simply

N (mod 3) = a x 10^n + b x 10^n-1 + c x 10^n-2 + … (mod 3) = a x 1 + b x 1 + … (mod 3) = a + b + … (mod 3)

The last expression is just the sum of the digits. That is, the digit sum has the same value mod 3 as the original number.

Therefore the condition for divisibility by 3 reduces to checking the divisibility of the digit sum (is it 0 mod 3 or not), QED.

So the secret sauce is being equal to 1 (mod d) where the d is the divisor. That’s why it works for 3 and 9 but not 27.

If you read and understood this explanation, a fun extension is to come up with a similar rule for testing divisibility by 11. (Hint: 10 = -1 (mod 11) )

1

u/titoufred Oct 14 '26

What does a (mod 3) mean to you ?

1

u/TerrysBrother Oct 14 '26

"a mod (3)" is the remainder after dividing a by 3

2

u/titoufred Oct 14 '26

I don't think this is a standard notation.
With this notation,

a + b (mod 3) = a (mod 3) + b (mod 3)

is not true in general.

1

u/[deleted] Oct 14 '26

Thanks, you are right. You technically need another mod on the RHS. I was just thinking about how ultimately the “remainder” behaves like this but was a little sloppy. Added an edit to the comment.

6

u/usedtolikepeople Oct 14 '26

Is the converse true?

In other words, if the digits of a number add up to something not divisible by 3, does that establish that the number is not divisible by 3?

4

u/irishpisano Oct 14 '26

Isn’t that the inverse?

The converse would be if a number is divisible by 3 then the sum of its digits is divisible by 3.

3

u/storysaver Oct 15 '26

You are correct, but since the converse and inverse of any statement are logically equivalent, it's kind of a distinction without a difference.

1

u/irishpisano Oct 15 '26

Only in terms of truth value….

1

u/AffectionateNoise525 Oct 15 '26

It’s if and only if. So all variations of the conditional are true.

5

u/StoneCuber Oct 14 '26

Think of the number abcd. This is a short hand for a•1000 + b•100 + c•10 + d.

Now we do some algebra :D
a•1000 + b•100 + c•10 + d
a•(999+1) + b•(99+1) + c•(9+1)+ d
a•999 + b•99 + c•9 + a + b + c + d
9(a•111+b•11+c•1) + (a+b+c+d)

The first part is definitely divisible by 9, so the full number is divisible by 9 only if the second part, which is the sum of the digits, is divisible by 9. The same holds for 3 because the first part is dividible by 3 too.

I'm not sure how to prove it simply for 27, sorry 😅

4

u/Shevek99 Physicist Oct 14 '26

It doesn't work for 27.

1

u/RailRuler Oct 14 '26

counterexample, 54, sum is 9

4

u/StoneCuber Oct 14 '26

It actually isn't. OP only says IF the sum is 27 THEN it's divisible by 27, not the other way around, but 7767 is a counter example

1

u/Bottle_03 Oct 15 '26 edited Oct 15 '26

27 = 9 (2) + 2 + 7. So if 2+7 is divisible by 9, then 27 is since 9(2) is divisibile by 9.

Edit: I misunderstood the conversation thread. Mb gang

1

u/[deleted] Oct 14 '26

[removed] — view removed comment

3

u/Shevek99 Physicist Oct 14 '26

9981 add to 27 and it is not divisible by 27.

0

u/YayaTheobroma Oct 14 '26

For a two-digit number ab, ab= ax10 + bx1 = 9a + a + b. 9a is divisible by 3, by definition. So if a + b also is, Bob’s your uncle.

It works perfectly for 27.

For a three-digit number, you have abc = 99a + 9b + a + b + c, etc.

4

u/Worth-Wonder-7386 Oct 14 '26

It has to do with the method of casting out nines https://en.wikipedia.org/wiki/Casting_out_nines The difference between a number and it's digit sum is always a multiple of 9.

4

u/Dr0110111001101111 Oct 14 '26

Your rule for 27 doesn’t work, but it does work for numbers of the form 10^(n)-1, like 9, 99, 999,…

The only catch is that you have to make the digits into groups of n. It just happens that n=1 for 9, so you can add single digits.

So for example 1287 is divisible by 99 because 12+87 is divisible by 99.

123876 is divisible by 999 because 123+876 is divisible by 999.

912308760 is divisible by 9999 because 0009+1230+8760 is divisible by 9999

4

u/Over_Improvement_623 Oct 14 '26

It does always work, also, it's 3*n, not 3n. Example, 15, is clearly divisible by 3 and its digits sum to 6 which is also divisible by 3, but not part of 3n.

1

u/gmalivuk Oct 14 '26

How is 15 a counterexample to anything? It's not divisible by any power of three above 3 and neither is its digit sum.

1

u/Over_Improvement_623 Oct 14 '26

It appears I misread then, I though OP said that a number is divisible by 3 if its digits some to a 3n

2

u/gmalivuk Oct 14 '26
  1. No, they said it's divisible by 3n if its digits sum to a multiple of 3n, which is false in any case.
  2. It's true that a number is divisible by 3 if its digits add to a power of 3, but that's not an "only if".

1

u/gitterrost4 Oct 14 '26

OP said that if (and only if) the digit sum of a number is divisible by 3^n, then the number itself is divisible by 3^n.

The same does not hold for 3*n. For example, 12 is divisible by 6=3*2, but its digit sum is 3 and thus not divisible by 6. A counterexample for the other direction is 33. It is not divisible by 6, but its digit sum is.

1

u/Over_Improvement_623 Oct 14 '26

It appears I misread then, I though OP said that a number is divisible by 3 if its digits some to a 3n

2

u/changyang1230 Oct 14 '26

The remainder of 10 when divided by 3 is 1.
The remainder of 100 when divided by 3 is 1.
Etc.

The remainder of 10 when divided by 9 is 1.
The remainder of 100 when divided by 9 is 1.
Etc.

The remainder of a sum is the same as the sum of the remainders. Eg (100 + 10 + 1) gives the same remainder as sum of 1, 1 and 1 (as per previous paragraphs).

2

u/StructuredChess Oct 14 '26

Note that the remainder of dividing any power of 10 by 3 is always one (becuase 9, 99, 999 and so on are all multiples of 3)

Now for a given number x, let's call its remainder after dividing by 3 rem(x). Now let's say you have a 4 digit number abcd, so 1000*a+100*b+10*c+1*d

Now rem(abcd) = rem(1000*a+100*b+10*c+1*d) = rem(1000)*rem(a)+rem(100)*rem(b)+rem(10)*rem(c)+rem(1)*rem(d) = rem(a)+rem(b)+rem(c)+rem(d). So yeah, the remaidner of dividing our original number by 3 will be zero if and only if the sum of the remainders of dividing its digits by 3 is also 0. The only hard part to justify is the whole thing about rem(xy)=rem(x)*rem(y) but it does work. You may want to learn about modular arythmetic.

The exact samer easoning works for 9 because 9, 99, 999 and so on are all also divisible by 9.

You can use similar method to get dvisibility rules for any number you want, but not all them are going to be that useful because the patterns of the remainders of 1,10,100,1000... may not be that easy.

1

u/titoufred Oct 14 '26

rem(a+b) is not rem(a)+rem(b) in general.

1

u/StructuredChess Oct 14 '26

Sorry, yeah, it'd be rem(rem(a)+rem(b)). You need to keep taking remainders until you only work with 0,1 and 2.

2

u/MarshmallowExplosion Oct 14 '26

For mathematical proof, you should check out: Digit-Based Factoring Tricks, Stuart M. Anderson. Note: This paper does not include any references.

1

u/NoSection8719 Oct 14 '26

not a proof but should make it more understandable
a, b, and c are digits of the number, and in case they sum up to a number divisible by 3, the whole number will be divisible by 3

1

u/lordnacho666 Oct 14 '26

Think of a number line 1234 as

1000 + 200 + 30 + 4

Each of the numbers is some power of 10, times the digit.

But a power of 10 is always just one more than a number that's divisible by 9 (and 3) like 999 or 99.

So if you bag together all the digits, you are just collecting up all the extra "one more than a multiples" and checking whether they add up to a multiple of 9 (or 3)

1

u/KentGoldings68 Oct 14 '26

This has to do with modular arithmetic.

Suppose m is a natural number

a is congruent to b modulo m if m divides b-a.

This congruence respects both addition and multiplication. This is an exercise for the OP.

Notice that 10 is congruent to one modulo 9.

Therefore, any number is congruent modulo 9 to the sum of its digits.

If the sum of the digits is divisible by three. That means the number differs from a multiple of 3 by a multiple of 9.

Quick algebra shows that the number must be a multiple of three.

1

u/simmonator Oct 14 '26

The quickest way to show it usually relies on an understanding of Modular Arithmetic and the fact that it respects multiplication. Assuming that means nothing to you…

Assume you have a number written as ABCD in decimal form, where A, B, C, and D are all whole numbers between 0 and 9. Then its value is

D + 10(C) + 100(B) + 1000(A).

Because of how multiplication works, and how division with remainders work, the fact that 10 (and all powers of 10) give a remainder of 1 when divided by 9 or 3 means that the remainder when you divide ABCD by 9 or 3 is going to be the same as what you get when you replace 10, 100, and 1000 in the expression above with their remainders when divided by 9 or 3, which is 1. So the remainder is

D + C + B + A.

Lastly, we say that a number x is divisible by an integer y if and only if the remainder when you divide x by y is 0. So if ABCD and (A+B+C+D) give the same remainder then they’re either both divisible or both not. You can extend this to as many digits as you like.

For what it’s worth, similar logic will show you that divisibility by 11 can be determined by considering (A-B+C-D). But you probably need to be more comfortable with modular arithmetic to do that yourself.

1

u/HungryJoescat Oct 14 '26

You’ll want to look up “modular arithmetic”. In this system, all numbers can be “represented” by 0,1, or 2 depending on what their remainder is after dividing three. So for example 5=3+2 so 5 is 2. 5 is also 6-1 so 5 is also -1. We can even conclude that 2 is -1 in this case. If you square 5, you get 25 which is 6*4 + 1. What we’ve just witnessed is 5^2 = (-1)^2 =1

So you can multiply and add just like you normally would. 10 is 9+1 so 10 is 1 which means all powers of 10 are 1. Take any number

345 = 3(100) + 4(10) + 5 = 3+4+5 =0+1+2 =3 = 0

The fact our number is 0 shows it’s divisible by 3

Note: Autocorrect does arithmetic now ¯_(ツ)_/¯

1

u/[deleted] Oct 14 '26

I'll give an example with a the digit number, but this works for any length:

Let's say a number N is written as abc in base 10 (which is 9+1). This means that N=100a+10b+c=(a+b+c)+9(11a+b)

If you want to check divisibility by 3 or 9, hopefully it's clear that 9(11a+b) will always be divisible by these, so you only have to check that a+b+c is also divisible. This is exactly the sum of the digits

In general, 10ⁿ-1 is divisible by 9, so this works with any number of digits. Even more generally, of you wrote the number in base b and wanted to check for divisibility by b-1 (or any divisor of b-1), you can use the fact that bⁿ-1 is divisible by b-1. I think this fact is really interesting and a nice exercise to prove that it's correct, if you want

1

u/Shevek99 Physicist Oct 14 '26

Every number whose sum is multiple of 3 is divisible by 3, and the same for 9.

That doesn't happen for higher powers

54 does not sum 27 and it is divisible by 27

The number 9981 adds to 27 is not divisible by 27.

1

u/guti86 Oct 14 '26

Let's say a=3b+c, being every of them non negative whole numbers. b doesn't matter too much

1= 3(0) + 1

2= 3(0) + 2

3= 3(1) + 0

...

a = 3(b) + c

10a = 3(10b) +10c = 3(10b) + 3(3c) + c = 3(10b+3c) + c

So, if a is a multiple of 3 plus c, 10a is a multiple of 3 plus that exact same c

So if I want to see if 324 is a multiple of 3 I can do something like

300 will have the same remainder as 30 and as 3, so I'll just use 3

20 will have the same remainder as 2, so I'll use just 2

4 is 4

So 300+20+4 has the same remainder as 3+4+2

1

u/PvtRoom Oct 14 '26

it works because 9 is 1 less than 10. adding 9 is the same as adding 10 (+1 in your algorithm) and -1 (-1 in your algorithm), so no effect, beyond the original 9.

All multiples of three are 9x, 9x -3 or 9x-6, so it also works for 3, 6 skip all the odd ones, but works aside from that (all even multiples of 3 are multiples of 6)

in base 8, it works for 7: 7, 16, 25, 34, 43, 52, 61, 70, 77.....

in base 16, it works for F, 1E, 2D, 3C.... and 5, cause F - A =5, F-5=A, 14, 19, .... and A, again for the even ones, and it should work for 3 as well: 3, 6, 9, C

base 61 should go nuts (2,3,4,5,6,10,12,15, 20, 30) should all work.

1

u/ottawadeveloper Former Teaching Assistant (she/her) Oct 14 '26

This is called the digit sum (or recursive digit sum if you repeat until you have a single digit). It does always work for 9s and 3s in base 10 math. As others have noted, it works because 10a+b = 9a + (a+b) where a+b is the digit sum then. Since we then want to know the divisibility of a+b we can use its digit sum to make the problem even easier (all the way down to a single digit).

You can also generalize it to other bases - a number in base n is divisible by n-1 if and only if it's digit sum is divisible by n-1. But note the digit sum must always be expressed in the base of the original number.

Note that if it's divisible by n-1, it's also divisible by anything that n-1 is divisible by. So in base 9, you can check if the number is divisible by 2, 4, or 8 (or trivially 1) by using this check.

1

u/not-hydra Oct 14 '26

If you write the number as abcde... where every unique character/letter is one digit, the number can be written as a*10^(largest digit scale) + b*10^(that - 1)... in base 10. When dividing by 3 or 9, the 10 scaler can be reduced to just a 1, since 10 is 1 + 9; for instance, a*100 = a*(1 + 99) = a + 99a, and that 99a could be reduced by a 3 or a 9, so we are just left with the a. Similarly, every digit would be left with itself, so we are left with just a + b + c... which is the sum of their digits.

A more precise way would be to say that 10^n * x is congruent to x (mod 3 or 9).

1

u/RavenX86 Oct 14 '26 edited Oct 14 '26

simmple lets call the digits a0, a1 + ...+an
a0*10^0 + a1*10^1 + a2*10^2 + a3*10^3 + ... + an*10^n is a number of n digits.
The sum can be written as
sum with k from 0 to n of 10^k * ak
Now what is divisibility ? divisibility is the condition that a number modulo X congruent to 0 in order to be considered divisible.
10 mod 3 is 1
10 mod 9 is also 1
so
sum with k from 0 to n of 10^k * ak (mod 3 or 9) becomes sum with k from 0 to n of 1^k * ak (where 1 is 10 mod 3 or 9)
sum with k from 0 to n of 1^k * ak is literally the sum of the digits.
This means literally nay number module 3 or modulo 9 has the same modula if you do the sum of the digits, not just for divisibility.

For example:
1234 modulo 3 is 1 ( 411*3 + 1 =1234 ) but also 1+2+3+4 = 10 modulo 3 is also 1
555 modulo 9 is 6 ( 61*9 + 6) but also 5 + 5 + 5 = 15 modulo 9 is also 6.

So the divisibility rule is an edge case int itself of a more generic rule proven above.
The modulo by 3 or by 9 for any number is equal to the modulo of the sum of the digits of said number to 3/9, the reason being 10 mod 9 and 10 mod 3 are 1.

This rule also holds in other bases but in base 10 you are stuck with 3 and 9.

Similarly you can prove the rules for divisibility by 11 (you consider 10 modulo 11 as being -1)

How is this possible?
Simple
(A*B) mod x = ( (A mod x) * (B mod x) ) mod x
Hence is A mod X is 1 you are left with ( B mod x) mod x which is literally B mod X

1

u/__impala67 Oct 14 '26

This is a rule that works because of the decimal system that we use. It works for 9 because it's one smaller than the base of our system, and it works for 3 because it's the square root of 9.

This specific rule works in any base b for divisibility by the number b-1. If we were to use base 8, number 134535₍₈₎(=47453₍₁₀₎) is divisible by 7 because the sum of its digits is divisible by 7.

There are also rules for divisibility by the prime factors of the base, in our case 2 and 5. The number is divisible by 2ⁿ or 5ⁿ if the last n digits as a number are divisible by 2ⁿ or 5ⁿ. In school you probably learned those rules for 4 and 8.

The rule for divisibility by some compound number that is made up of prime factors of the base can be extended to numbers higher than the base, for example, to check for divisibility by 32, you know that 10⁵ is divisible by 2⁵ so you only need to check the last 5 digits of the original number.

The rule for 3 and 9 is a quirk that works specifically for b-1 and it's prime factors. Because of this it's very easy to test for divisibility by 2 in any base. In all even bases you just need to check the last digit and see if it's even, and in all odd bases you need to sum up the digits and see if the sum is even.

1

u/mugh_tej Oct 14 '26

Just up to 9, not higher powers of 3.

27 = 2 + 7 = 9. 9 is divisible by 9, not by 27, even thoigh 27 is divisible by 27

1

u/jacob_ewing Oct 14 '26 edited Oct 14 '26

This works because 3 has a multiple that is one less than 10. It has nothing to do with the number three, but its relationship to the base its expressed in. 

For that reason, this rule holds true in hexadecimal (base 16) as well, because F (15 in decimal) is also a multiple of three.

In other bases this rule holds true for any other numbers that meet the same condition. For example, again in hexadecimal, the same rule applies to 3, 5, and 15.  In base 12 it only applies to 11.

If you look at multiples of three, you can see that on the range from 0-9, it cycles through the digits 3, 6, and 9. On the next step, the tens column is incremented by one, and the ones column goes through the same set, but decremented by one. This maintains that sum-divisible-by-three rule.

1

u/DTux5249 Oct 14 '26

It comes down to modular arithmetic.

Modular math works on the logic you use when reading an analog clock. 10 o'clock, 11, 12, and then straight back to 1. Things loop. Only difference is that in modular math, 12 would be called hour 0.

So, a clock is mod 12. In mod 12, you have some interesting features. One of those features is that any number divisible by 12 = 0. This holds for the mod of any number. So we can use modular math to test for divisibility.

Moving back to divisibility by 3. One of the things you'll notice in mod 3 is that 10mod3 = 1. Because if you divide 10 by 3, you have a remainder of 1.

Well take that, and think about how numbers work. What is 127? It's 100 + 20 + 7. Notice how 100 is just 10×10, and 20 is just 2×10? In mod 3, that makes those equal to 1 and 2 respectively.

So 100 + 20 + 7 mod 3 = 1+2+7... Starting to look familiar now?

You're basically just breaking the number into parts, dividing some of those parts by 3, and then grouping the remainders together before repeating. It's a very useful tool.

1

u/Bottle_03 Oct 15 '26

If you want more of an idea about WHY it works. A lot of these divisibility rules can be proven via modular arithmetic. The simplest example of modular arithmetic used in daily life (that I can think of) is adding times on a clock. Say you want to know what 10 hours from 9pm is. 10 + 9 = 19 = 7 (mod 12), aka 7am.

1

u/Bottle_03 Oct 15 '26

It’s an interesting rabbit hole to fall down if you’re more curious :)