Hacker News new | ask | show | jobs
by tejapr 3808 days ago
a ^ (n - 1) ~= 1 mod n if n is prime, Fermat's Little Theorem.

3 is prime. 34240923842043983204982 is divisible by 3 - 1 = 2.

ab mod n = [a mod n * b mod n] mod n

So, we can automatically infer that 2 ^ 34240923842043983204982 ~= 1 mod 3.

After subtracting 1, it will be divisible by 3.

Alternatively, you could notice that 2 ^ 2 ~= 1 mod 3, which implies 2 ^ 4 ~= 1, 2 ^ 6 ~= 1, so 2 ^ all even powers will be congruent to 1 modulo 3.

So 2 ^ x - 1 will always be divisible by 3 for even x.