Originally posted by TheMaster37The algorithms for testing divisibility by 7 I've come across are all horribly complicated, do you know one that's relatively simple? From the top of my head, these are the divisibility tests I know up to 25:
[...] There is even one for multiples of 7, but that's a bit trickier.
1: trivial
2: even number
3: sum of digits is divisible by 3
4: last two digits divisible by 4
5: ends in 0 or 5
6: divisible by 2 and 3
7: ???
8: last three digits divisible by 8
9: sum of digits equals 9
10: ends in 0
11: alternating sum of digits divisible by 11
12: divisible by 3 and 4
13: ???
14: divisible by 2 and 7
15: divisible by 3 and 5
16: last four digits divisible by 16
17: ???
18: divisible by 2 and 9
19: ???
20: divisible by 4 and 5 (more simply put: ends in 00, 20, 40, 60 or 80)
21: divisible by 3 and 7
22: divisible by 2 and 11
23: ???
24: divisible by 3 and 8
25: ends in 00, 25, 50 or 75.
Does anyone know a clever way to fill some of the blanks?
The well known rule for divisibility by 7 is easier than it sounds:
1) Take the last digit of the number and double it.
2) Subtract the number obtained from 1) from the remaining number.
3) If this number is divisible by 7, so was the original number, otherwise it wasn't (zero is considered to be divisible by 7).
Here's an example:
Original number: 42357
Last digit is 7, doubling this makes 14, so we subtract 14 from 4235 (the original number without the last digit) making 4221.
To determine if 4221 if divisible by 7 we do the same thing - giving us the sum 422 - 2 = 420.
And again with 420: 42 - 0 = 42.
Just for fun we'll do the algorithm on this last number, 42: 4 - 4 = 0
So 42357 is divisible by 7.
The problem, of course, is that we have to do so many calculations to determine whether the original number was divisible by 7, probably more than if we had done a simple long division.