We all learn in elementary school that a number is divisible by 2 if the last digit is even. A number is divisible by 3 if the sum of the digits is divisible by 3. A number is divisible by 5 if its last digit is 0 or 5. Etc.

But imagine we were born with 8 fingers on each hand and did arithmetic in base 16, also called hexadecimal. Or suppose schools decided to teach children hexadecimal instead of decimal to give them a head start in computer science. We would count 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F, 10, 11, …

What would divisibility rules look like? Here are the simplest rules.

*n* divisible by 2 if its last digit is even.
*n* is divisible by 3 if its digit sum is divisible by 3.
*n* is divisible by 4 if its last digit is 0, 4, 8, or C.
*n* is divisible by 5 if its digit sum is divisible by 5.
*n* is divisible by 6 if it is divisible by 2 and 3.
*n* is divisible by 8 if it ends in 0 or 8.
*n* is divisible by A if it is divisible by 2 and 5.
*n* is divisible by F if its digit sum is divisible by F.
*n* is divisible by 10 (i.e. sixteen) if its last digit is 0.

In this list “digit” means hexadecimal digit.

There are also rules for checking divisibility by 7 and 11 (i.e. seventeen) in hexadecimal analogous to the rules for divisibility by 7 and 11 in decimal.

To test divisibility by 7, split off the last digit from the rest of the number. Triple it and subtract from what’s left of the original number. Repeat this process until you get something you recognize as being divisible by 7 or not.

For example, suppose you start with F61. Split this into F6 and 1. Subtract 3 from F6 to get F3. Now split F3 into F and 3. Subtract 9 from F to get 6. F61 is not divisible by 7 because 6 is not divisible by 7. The explanation for how this works is completely analogous to the corresponding rule in base 10.

You can test for divisibility by 11 in base 16 (i.e. by seventeen) just as you’d test divisibility by 11 in base 10 (or any other base). Add up the digits in an odd position and subtract the sum of the digits in an even position. For example, suppose you start with 135B8. The digits in odd position sum to 1 + 5 + 8. The digits in even positions sum to 3 + B. Both sums are equal, so there difference is 0, which is divisible by 11, so 135B8 is divisible by 11.

There’s nothing special about base 16 or base 10. You could come up with analogous divisibility rules in any base.

## Related posts

One of the nice things about the forth language is the ease with which you can switch number bases. Forth doesn’t particularly care which base it is displaying although you will have to learn to do your work in reverse Polish notation, popularized by many of the old HP calculators.

I found a strange fascination in base three (or ternary) notation. A lot of numbers seem to line up in interesting patterns and, of course, division by 3 becomes a breeze.

Binary/hex rules for now, but it has been shown that ternary is a little more efficient for most computational tasks. If only we had the hardware!

Wonder what the “best” human-friendly representation of base 3 data would be? How long is a tryte?

Yhanks for this nice topic..

Nice article on Divisibility rules for Hex.

If anyone is interested in to learn divisibility rules for numbers, please download this app for iPhone/iPad.

screen cast of the apphttp://www.youtube.com/watch?v=xLSQ7nKsrDU

Download link: http://itunes.apple.com/in/app/learn-divisibility-test/id467896263?mt=8

You forgot “divisible by 15 if the digit sum is divisible by 15”. The rule “divisible by n-1 if the digit sum is divisible by n-1” is true for every number base n.

It’s interesting that there are many rules which correspond to the ones in the decimal system, such as how the rule for 8 is analogous to the one for 5 in the decimal system.

If anything, 16 is a fairly factorisable number, which opens up more possibilities (e.g., the rules for 2, 4, 8 and 16 vs. the rules for 2 and 5 in the decimal system). Not all numbers are divisible of course, but then that’s where direct hexadecimal division can come in handy.