What is the fastest known way for testing divisibility by 7? Of course I can write the decimal expansion of a number and calculate it modulo 7, but that doesn't give a nice pattern to memorize because 3 is a primitive root. I'm looking for alternative ways that can help you decide when a number is divisible by 7 by hand.

I'm sorry if this is a duplicate question, but I didn't find anything similar on the site.

  • 4
    Compute the alternating digit sum in base $10^3$. $n$ is divisible by $7$ if and only if the alternating digit sum (in base thousand) is divisible by $7$. Repeat until you have a result between $0$ and $999$ (both inclusive). – Daniel Fischer Sep 10 '13 at 12:41
  • 1
    You didn't find this? – rschwieb Sep 10 '13 at 12:46
  • 1
    Here's another solution where Gone comforts us that we don't need to memorize a mess of divisibility rules, we merely need to evaluate a radix polynomial in nested Horner form, using modular arithmetic. Now I can sleep better... – rschwieb Sep 10 '13 at 12:49
  • 2
    Gone's generic recipe notwithstanding I would use the idea in Daniel's comment. – Jyrki Lahtonen Sep 10 '13 at 13:04
up vote 23 down vote accepted

One rule I use pretty much is:

If you double the last digit and subtract it from the rest of the number and the answer is: 0, or divisible by 7 then the number itself is divisible by 7.

Example:

  • 672 (Double 2 is 4, 67-4=63, and 63÷7=9) Yes
  • 905 (Double 5 is 10, 90-10=80, and 80÷7=11 3/7) No

If the number is too big you can repeat until you find the solution.

  • 11
    +1 It is perhaps worth mentioning this algorithm works because $\;10x+y\;$ is divisible by seven iff $\,x-2y\;$ is , $\,x,y\;$ digits. – DonAntonio Sep 10 '13 at 13:00
  • 2
    This is a good rule, and one I use. It is worth pointing out that (unlike the test for $9$) it does not preserve a non-zero remainder. So you know whether the original number is divisible by $7$, but not the remainder if it is non-zero. – Ross Millikan Sep 10 '13 at 13:10
  • 3
    @DonAntonio Looks wrong at first glance because the difference between $10x+y$ and $x-2y$ is $9x+3y$ and has no reason to be a multiple of $7$. But indeed the trick makes use simply of $7|21$, i.e. that $10x+y-10\cdot(x-2y)=21y$ – Hagen von Eitzen Sep 10 '13 at 13:13
  • 3
    If it helps you can do some elementary reductions first - $672$ to $602$ or $905$ to $205$ – Mark Bennet Sep 10 '13 at 13:38

Another way to do this is to use a divisibility graph (see: How does the divisibility graphs work?). They're not to difficult to remember/generate for small numbers.

Divisibility Graph For 7

To compute mod 7 for n: Start at 0. For each digit x in n traverse x black arrows in the graph then, in between digits, follow the blue arrows.

example:

Take 6594:

  1. Digit is 6, traverse 6 black arrows, ending on node 6 then follow blue arrow to node 4
  2. Digit is 5, traverse 5 black arrows, ending on node 2 then follow blue arrow to node 6
  3. Digit is 9, traverse 9 (or 2 as 9 mod 7 = 2) black arrows, ending on node 1 then follow blue arrow to node 3
  4. Digit is 4, traverse 4 black arrows, ending on node 0

6594 mod 7 = 0

Here are some pointers:
Divisibility by 7
Divisibility rules

  • 10
    Hi Mufasa: those are nice links, but links like this are vulnerable to disappearance. Any way you could summarize the basics? People will also appreciate that you put more into your answer than link pasting. – rschwieb Sep 10 '13 at 12:53

The best way to test if a number is divisible by any other number is by deducting the number n times and check whether the remainder is divisible by n. for example 861-7n/7. Here 7n must be lesser or equal to 861.

  • This is actually more labor intensive than long division... – apnorton Jul 30 '14 at 0:55

I created this algorithm that is very quick: N = a,bcd; a' = (- cd mod 7 + a) mod 7; If 7|a'b then 7|N; If N is larger repeat the procedure. It works because - cd mod 7 ≡ 6 cd; 6 cd goes to the place value of the thousands. Then N is submitted to the addition of 6,000 cd and to the subtraction of 1 cd: 6,000 - 1 = 5,999 and 7|5,999. Each time the procedure is applied a multiple of 7 is added to N. With practice it may be applied entirely through mental calculation. Watch this video that shows the application of the algorithm: https://www.youtube.com/watch?v=d8Bmf9BNonU

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.