Granted that singingbanana's solution is the bare-bones needed.

Hand calcs can be reduced somewhat by observing that the progressive divisibility rule forces every second digit ( b d f h ) to be even. Corollary: the remaining five digits must be odd.

The modular 8 formula, (4f+2g+h)|8, can be simplified to (2g+h)|8 since, knowing f is even, 4f|8, and the f term drops out.

[Notation used here:( M)|N reads M is divisible by N. Equivalently (M) mod N = 0.]

The six term mod 6 formula can also be efficiently replaced by observing that any number divisible by 6 must also be divisible by 6's factors, 2 & 3. Again knowing f is even, the divisible by 2 constraint is met. The (a+b+c) terms are already defined to be divisible by 3, so the formula for 6 can be (d+e+f)|3.

The corollary for odds is useful when dealing with 4 & 8.

By submitting this form, you accept the Mollom privacy policy.