But what I hadn't thought about (though nothing precluded it), is what happens when the factor is greater than the base number.
For example, before we talked about numbers which were multiples of 9. But what about 11, which is 1 greater than the base?
Well, it turns out that that works too!
Remember that the constraint is that
a + b*r^1 + c*r^2 + .. + k*r^n
be a multiple of f - the factor we're looking for.
Now, originally I'd imagined that f was less than than the base value (ie <10) giving a positive remainder r. But it still works for negative r.
The simplest case is that of the numbers which are multiples of 11, which gives remainder of -1. Pluging in r=-1 into the above equation, you see that the equation for 11ssss reduces to
a - b + c - d + ...
ie you just alternatively add and subtract the digits of the original number (going from right to left), then check to see whether the answer is a multiple of 11 or not.
One thing to be aware of is that the sum can equal 0. Which implies that its a multiple of 11, as in the case of 121 (+1-2+1 = 0).
Hello Simon,
ReplyDeleteInterested in cryptography?
Pierre
Surpisingly, I am. Though I don't think the NSA, MI6 or ANSSI have anything to worry about!
ReplyDelete