Hacker News new | ask | show | jobs
by sweezyjeezy 530 days ago
Nice - the n1 + n3 = n2 + n4 equality is only necessary (mod 11) e.g. 9020 works - this is because 99...99 with even # of 9s is divisible by 11 and with odd # 9s is divisible by 11 if we subtract 9 (or add 2) so then is = -2 mod 11. So then for example with 4 digits

  1000a + 100b + 10c + d = [a + b + c + d] + [999a + 99b + 9c]
                         = [a + b + c + d] - 2a - 2c (mod 11)
                         = (b + d) - (a + c) (mod 11)