Continuing the discussion from Mental Multiplication: Useful Facts and Exercises: where in the end it was suggested to find a **general algorithm** for testing divisibility of numbers.

First of all, you just need to check the divisibility by primes. For a number like 6 you can then simply check if it is both: divisible by 2 and divisible by 3. Ignoring 2 and 5 for just a minute, primes end in either: 1, 3, 7, or 9.

We’ll do something similar to what is described here. For any number ending in 9, you just take the tenth digit plus one; so let’s start with 19 which will then be 2.

## Check if 2774 is divisible by 19

Take the last digit, multiply by 2, and add it to the rest of the digits. Rinse and repeat:

- 277+{\color{red}{4}}*2 = 28{\color{green}{5}}
- 28+{\color{green}{5}}*2 = 3{\color{blue}{8}}
- 3+{\color{blue}{8}}*2 = 1{\color{maroon}{9}}
- 1+{\color{maroon}{9}}*2 = 1{\color{gray}{9}}

We come out at 19 and thus 2774 is in fact divisible by 19. Stop when you like though. If you know that 38 is twice 19, don’t even bother making it to 19. Also, the last line is only there to show that it’ll now remain 19.

## Check if 2436 is divisible by 29

Take the last digit, multiply by 3, and add it to the rest of the digits. Rinse and repeat:

- 243+{\color{red}{6}}*3 = 26{\color{green}{1}}
- 26+{\color{green}{1}}*3 = 2{\color{blue}{9}}
- 2+{\color{blue}{9}}*3 = 2{\color{maroon}{9}}

We come out at 29 and thus 2436 is in fact divisible by 29. You can try yourself for 39 (4), 49 (5), 59 (6), etc. Also note that for 9, we’d be multiplying by 1 and hence the abbreviated common rule of adding all the digits to see if it’s a multiple of nine.

## Numbers not ending in 9

Basically, you just make them end in 9 by taking a multiple that ends in 9. So to check if some number is divisible by 13, you’d do the same as above but multiply by 4. If you want to check for 23 then 23x3=69 and you use 7 instead.

## The negative osculator

11 and 17 above come out pretty big, so we’ll make use of the fact that just like being **one under** with 19, we are **one over** with 11 and can use 1. Similarly, we can use 17x3=51 and use 5 to check for divisibility by 17. **All we have to do now is subtract instead of add.**

## Check if 2583 is divisible by 21

Take the last digit, multiply by 2, and subtract it from the rest of the digits. Rinse and repeat:

- 258-{\color{red}{3}}*2 = 25{\color{green}{2}}
- 25-{\color{green}{2}}*2 = 2{\color{blue}{1}}
- 2-{\color{blue}{1}}*2 = 0

Obviously, you can stop at 21 already, but the last line is there to show that it’ll always stay 0 now.

## In conclusion

When the number **ab** ends in 9, drop **b** and use **a+1** with addition. If the number **ab** ends in 1, drop **b** and use **a** with subtraction.

- Numbers ending in 3 follow the logic for numbers ending in 9 when multiplied by 3.
- Numbers ending in 7 follow the logic for numbers ending in 1 when multiplied by 3.

Add 2 and 5 back to the mix and you’re good to go. Numbers divisible by 10 are divisible by 5 and **end in 0 or 5** but also divisible by 2, so they have to be even and **cannot end in 5**. Same logic for other compounds as well… 39 is both 3 and 13, but repeatedly adding the last digit times 4 might turn out faster.

The problem with the wiki link that @RobertFontaine had given in the post liked here at the top, is that you can usually drop something for simplicity. Granted these simplifications make things faster… imagine successively adding the last digit times 1 in case of divisibility of 3 or 9 instead of just adding them up; which obviously accomplishes the same.

Problem is that nobody knows anymore why divisibility by 7 could be checked by either adding the last digit times 5 successively or subtracting the last digit times 2 successively. Hope this post makes it clear that 7*7=49 \to 5 or 7*3=21 \to 2 are equally valid for use with addition or subtraction, respectively.

Lastly, note that the positive (5) and negative (2) osculator above add to the denominator (7). So if you got one osculator determined, you can get the second one by simply subtracting from the denominator.