The ability to check whether a number is divisible by, say 4 or 9, seems to be useless at first.
But it could be a time saver when you're trying to check the result of your calculation without resorting to a calculator. Or it could be a mental trick (or what Arthur Benjamin says as Mathemagic) which you can use it for fun while drinking some beers in the pub.
Here are some of them:
- Divisibility by 2:
Very simple, check if the last digit is even or not. Thus 928474712 is divisible by 2, while 361635 is not.
- Divisibility by 3:
Quite simple, sum up all the digits in that number, and check if it's multiples of 3.
Say you have a 7 digit number 9282648.
Sum up all the digits in that number, i.e: 9 + 2 + 8 + 2 + 6 + 4 + 8 = 39
39 is divisible by 3 (39 / 3 = 13), thus 9282648 is divisible by 3 ( 9282648 / 3 = 3094216 )
or you can go several steps further, keep summing up the digits, i.e. 3 + 9 = 12 then 1 + 2 = 3
- Divisibility by 4:
Check if the last 2 digits are divisible by 4( or if you didn't memorize multiplication table of 4, then check if you can divide the last 2 digits of the number twice, since, you know 4 = 2 x 2 ).
Example: 948137924 is divisible by 4, since 24 is 6 x 4. ( 948137924 / 4 = 237034481 )
- Divisibility by 5:
Check if the last digit is 5 or 0 (e.g. 242452525, or 80808083130 )
- Divisibility by 6:
Similar to divisibility by 3, but the original number should be even number.
E.g. 9282648 is divisible by 6 and 3, while 9282645 is divisible by 3 but not by 6.
- Divisibility by 7:
For divisibility by 7, I only know the trick that uses recursive method.
- Separate the digits of the number into last digit and the rest of the digits.
- Do this: (rest of the digits) - (2 x last digit)
- Check if the result is multiple of 7, if yes, then voila, else repeat from step 1
Example: 2443
- last digit = 3, rest of the digits = 244
- 244 - (2 * 3) = 238
- Not sure if it's divisible by 7
- last digit = 8, rest of the digits = 23
- 23 - ( 2 * 8 ) = 7
- Divisible by 7
- Divisibility by 8:
The last 3 digits should be divisible by 8. If it's hard to check if 3 digits number is divisible by 8, try to divide it by 2 for 3 times (since 8 = 2 x 2 x 2)
Example: 24752, last 3 digits = 752.
If it's hard to see whether 752 is divisible by 8, then keep subtracting 752 with 200, until you reached a number below 200, which is in this case 152, which is divisible by 8 (152 / 8 = 19).
Thus 24752 is divisible by 8 (24752 / 8 = 3094)
- Divisibility by 9:
Similar to divisibility by 3, but this time it will end up with multiple of 9, or if you keep doing it, it will end up with 9.
Multiple of 9 is very pretty, since
1 x 9 = 09 | 6 x 9 = 54 |
2 x 9 = 18 | 7 x 9 = 63 |
3 x 9 = 27 | 8 x 9 = 72 |
4 x 9 = 36 | 9 x 9 = 81 |
5 x 9 = 45 | 9 x10= 90 |
The sum of the digits of the result will always be 9.
Example: 1111111101 is divisible by 9, since 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 = 9. (1111111101 / 9 = 123456789)
or 7992 is divisible by 9, since 7 + 9 + 9 + 2 = 27, and 2 + 7 = 9. (7992 / 9 = 888)
There you go, I posted it after trying to figure out what's being outputted by OpenCV's HOGDescriptor's compute function, since it gives me a 1D vector of floating numbers with the size of 7 digit numbers. Then after pondering a while, I realized that the size of that 7 digit numbers is divisible by 9, thus it should be a flattened version of 9 normalized bins. You don't need to understand what I am saying though.
Log in to comment