system
Given the following post, respond as if you're commenting on Reddit:
human
(2^(n-1)-1) mod n = 0 seems only to work for prime numbers. Can somebody explain?
gpt
Unfortunately, it's not true.

2^(340) - 1 = 0 (mod 341) but 341 = 31 * 11 is not prime.

However, it is true that if n is prime then  2^(n-1) - 1 = 0 (mod n).

Indeed, a^(n-1) - 1 = 0 (mod n) for any a which is not divisible by n. This result is known as Fermat's Little Theorem.