What Is the Divisibility-by-7 Rule, and Why Does It Work?
At a glance
- 1. Split off the last digit
Write the number as ten times the remaining part plus its last digit.
- 2. Double and subtract
Subtract twice the last digit from the remaining part.
- 3. Repeat if useful
Apply the same operation to the new number until the result is easy to check.
- 4. Use congruence laws
Each step preserves whether the number is congruent to zero modulo seven.
A useful divisibility test for 7 is to remove the last digit, double it, and subtract that doubled digit from the part that remains. You can repeat the operation until the result is small enough to recognize. For example, the test reduces 1729 to 154 and then to 7, so 1729 is divisible by 7.
The reason the test works is that each step preserves divisibility by 7. Congruence arithmetic makes that preservation precise and also explains which arithmetic operations are safe when working modulo 7.
The divisibility-by-7 rule
Write an integer as
where is its last digit and is the number formed by the other digits. The rule replaces by . Then
Here, means that is divisible by 7. The rule works for negative results too: a negative integer is divisible by 7 when it is a multiple of 7, such as .
Why the rule works modulo 7
The notation means that is divisible by 7. In particular, a number is divisible by 7 exactly when it is congruent to 0 modulo 7.
Since , splitting off the last digit gives
Multiplying both sides by 5 is valid here because 5 has a multiplicative inverse modulo 7: . Thus
The final step uses . Also, multiplying a number by 5 does not change whether it is congruent to 0 modulo 7: 5 is not divisible by 7 and has an inverse modulo 7. Therefore is divisible by 7 exactly when is divisible by 7.
Some versions of the test add five times the last digit instead of subtracting twice the digit. These give the same test because .
Worked example: test 1729
Apply the rule to 1729, taking care to separate the last digit at each step:
Now apply it to 154:
Because 7 is divisible by 7, the original number is divisible by 7 as well. In fact, . Each arrow preserves divisibility, so you may stop as soon as the result is a number whose divisibility you can decide.
Congruence arithmetic laws
Congruences allow you to replace numbers with simpler numbers in sums and products. If and , then
and
For example, modulo 7, and . So , and . The laws follow from the definition: congruent numbers differ by multiples of the modulus, and sums and products of such expressions still give differences divisible by that modulus.
More generally, you can add or multiply congruences by the same integer. You can also substitute congruent values into any polynomial with integer coefficients. For instance, if , then .
Why division needs care
You cannot always cancel a factor in a congruence. Cancellation is valid modulo only when the factor is relatively prime to . In particular, modulo 7 you may cancel any factor not divisible by 7, because 7 is prime. For example, implies .
But modulo 8, cancellation can fail: , although . The factor 2 shares a divisor with 8, so it has no multiplicative inverse modulo 8. Similarly, dividing a congruence by 7 is not a valid operation modulo 7. When a factor is invertible, “division” in modular arithmetic means multiplying by its modular inverse.
Common mistakes
- Subtracting the digit only once: The rule requires subtracting twice the last digit, not the digit itself.
- Stopping at a large result: You can repeat the operation; a small result is easier to check.
- Treating a negative result as failure: For example, is divisible by 7.
- Dividing or cancelling without checking: Confirm that the factor has an inverse modulo the modulus before cancelling it.
References
- Elementary Number Theory and Its Applications — Kenneth H. Rosen
Spotted an error? Send a correction. Read how we write and check articles in our editorial policy.