Here is a more formal (and perhaps simpler) way to prove jt's example of why a number is divisible by 7 if and only if its tens part less twice its ones part is.

Let x be the original number with tens part d and ones part u, and have a remainder of r when divided by 7, ie:

x = 10d + u = r mod 7

The number x will be divisible by 7 if r = 0. But it's easy to see that 3d + u = r mod 7 as well, since we can subtract 7*d without affecting the remainder.

Now subtract three times the second expression from the first:

   10d + u    ( = r mod 7)
 -3(3d + u)   ( = -3*(r mod 7))
   --------
   = d - 2u   ( = -2r mod 7)

This is just modulo arithmetic. So if r = 0 (meaning the original x was divisible by 7) then so is d - 2u above, which proves the "if" condition. If r is not 0 then d - 2u has a remainder of -2r which is not a multiple of 7, since r is not, which proves the "only if" part.


You can play these sorts of games with really any divisor, which (to answer some protests above about how "inefficient" this sort of thing is) if you're lucky produces an algorithm that is faster as a quick test than long division, especially if you're doing it in your head. Try this:

Is 242,630 divisible by 19?

While you are off doing that the hard way, jt and I will be adding twice the ones part to the tens part repeatedly, i.e. (d + 2u) in the formulation above:

242630 => 24263 => 2432 => 247 => 38 => 19.

Victory -- it is divisible by 19. We will sit down and have tea while we wait for you to do the long division in your head without making a mistake, which looks like:

    12770
19|242630
   19
   --
    52
    38
    --
    146 
    133
    ---
     133
     133
     ---
       0
       0
       -

And here's why d + 2u works for 19, using the same argument as we did for 7:

   10d + u    ( = r mod 19)
   10d + u    ( = r mod 19)
   --------
   20d + 2u   ( = 2r mod 19)
 - 19d        (    0 mod 19)
   --------
     d + 2u   ( = 2r mod 19)

and so d + 2u is 0 mod 19 if and only if r = 0, which makes the original number divisible by 19, exactly as we did for 7.