News for hackers. Stuff that matters.
Re:Divisibility by 7 is a Walk on a Graph (2009) by colinodell on Sunday November 08, 2015 @10:48PM (#10531276)
So why does this work?
Re:Divisibility by 7 is a Walk on a Graph (2009) by Jtsummers on Sunday November 08, 2015 @11:17PM (#10531355)
...There was another answer here that seemed close.

I'm not sure the best way to express it, but here's what I've got:

Allow me to use a shorthand, N = AB where AB is shorthand for 10 * A + B, and B is the least significant digit. IF N is divisible by 7, then AB = 0 (mod 7). This allows us to do the following manipulations:

  AB = 0 (mod 7)
  10*A + B = 0 (mod 7)
  3*A + B = 0 (mod 7)
  5*(3*A + B) = 5*0 (mod 7) // EDIT: had -2 on the RHS, that was correct but confusing
  A + 5*B = 0 (mod 7)
  A - 2*B = 0 (mod 7)
So we've arrived at drfuchs' method. You only need to repeat the process until you've proven to yourself that A - 2 * B is divisible by 7 or not.

That's all I've got. I ran a half-marathon yesterday, and I've been up for 16 hours today. My brain might work better tomorrow.

EDIT: changed the steps a bit, had some unneeded ones. Also, this shows that you can use addition instead of subtraction, but you won't be moving towards 0, but you still have to be able to recognize that the new number is divisible by 7.

Re:Divisibility by 7 is a Walk on a Graph (2009) by jacobenget on Sunday November 08, 2015 @11:57PM (#10531473)
Thanks for this explanation! I was about to post something similar after working the math out, but I'm sure my answer would have been twice as long and less clear.
Re:Divisibility by 7 is a Walk on a Graph (2009) by hcarvalhoalves on Sunday November 08, 2015 @10:52PM (#10531290)
50 years from now this will be called "drfuchs last theorem"
Re:Divisibility by 7 is a Walk on a Graph (2009) by newsignup on Sunday November 08, 2015 @11:17PM (#10531353)
with the scribble "but it took decades for me to realize why it obviously works" somewhere in the margins and stating that there wasn't enough room to write that down though..
Re:Divisibility by 7 is a Walk on a Graph (2009) by mmastrac on Sunday November 08, 2015 @11:10PM (#10531334)
You are subtracting enough 21s (ie: X * 21) to make the last digit zero. Since 21 is obviously a factor of 7, subtracting those should yield a factor of 7.

You can then divide by zero because if X is a factor of 7 and ends in zero, X / 10 is a factor of 7 as well.

Re:Divisibility by 7 is a Walk on a Graph (2009) by pervycreeper on Sunday November 08, 2015 @11:01PM (#10531311)
21=3*7

you are subtracting multiples of 21, then dividing by 10, which is coprime with 7

Re:Divisibility by 7 is a Walk on a Graph (2009) by orbitur on Sunday November 08, 2015 @11:24PM (#10531381)
The examples subtracted 10, 16, etc... Those aren't multiples of 21.
Re:Divisibility by 7 is a Walk on a Graph (2009) by chadzawistowski on Monday November 09, 2015 @12:06AM (#10531486)
Since you scratched off the last digit, 10 is really 100, plus 5 for the digit you scratched off = 105.

105 is a multiple of 21.