1==1 (mod 11)
10==-1 (mod 11)
100==1 (mod 11)
1000==-1 (mod 11)
Therefore 123456 == 6 - 5 + 4 - 3 + 2 - 1 (mod 11) == 3 (mod 11)
Obviously you may need to do a further % operation after adding and subtracting digits, but it should be reasonably fast.
what is 90 % 11 ?
ReplyDeleteThis comment has been removed by the author.
ReplyDelete90 % 11 = 0 - 9 = -9 % 11 = 2
ReplyDelete