Read · 1 min
To check whether a number is divisible by 10 - 1 we take k digits from the end of the number and keep adding to this number the next k digits until we exhaust the original number. The remainder of the sum we get divided by 10 - 1 is the remainder of the original number. This is because each chunk of k digits from the second chunk from the end onwards is a multiple of some power of 10, i. e. (10 - 1) + 1, so we can "cast out" the part inside the parentheses as it has a remainder of zero and be left with the immediately smaller power as a factor, and we can do this repeatedly, until what's left is the chunk to the power of 1.
For the remainder of the division by 10 + 1 we take k+1 digits from the end, and add the next k +1 digits multiplied by (-10). We start with j=1 and repeat the process until the digits of the number are exhausted, incrementing j by 1 each time, until j=k, at which point we put down -this rule should supersede the previous one at this point, if only to make calculations easier- the whole factor as (-1) and start over, with j=1 for the next multiplication. The remainder of the division of the final sum by 10 + 1 gives the remainder of the original number. This is because each chunk of k+1 digits from the second chunk from the end onwards is a multiple of some power of 10, i. e. (-10) (mod 10+1) in increasing powers. When these powers reach k, since (-10) = (-1)*10 the result (mod 10+1) is (-1). This last number is multiplied by 10 to give the next power so the net result is multiplication by -10. For example, the remainder of 1234567 divided by 11 is 67+45+23+1=126=26+1=27=5. The remainder of 1234567 divided by 101 is 567-2340-1=-1774=-1000-774=10-774=-764=-57=44. The remainder of 1234567 divided by 1001 is 4567-1230=3337=334.