mathprimesxorbitwise-xor

Can xor of distinct prime numbers be 0?


I have tried this exercise for a few sets e.g. {2, 3, 5}, {5, 11} where xor of elements is not 0. My intuition suggests that it will always be non-zero but I am unable to prove it. I searched on the net but didn't find anything. Any help will be appreciated.


Solution

  • Condensed from comments to your question:

    For two distinct primes, bit-wise XOR will not be zero. In general, XOR of two numbers is zero if and only if the two numbers are equal.

    For three distinct primes, from considering the least significant bit only, we see that not all three primes can be odd numbers. But there exists only one even prime, namely 2. Then the remaining primes, both odd, must be identical on every bit except the second-least significant bit where they must be different. They are therefore twin primes of the form 4k+1 and 4k+3 (note that twin primes of the form 4k-1 and 4k+1 do not satisfy the requirement). So the solutions for three primes are { 2, 5, 7 }; { 2, 17, 19 }; { 2, 29, 31 }; { 2, 41, 43 }; ....

    For four primes, there are simply so many ways it can happen. From a simple program listing all occurrences with all primes under 50, I get: { 3, 5, 11, 13 }; { 5, 7, 17, 19 }; { 3, 5, 17, 23 }; { 11, 13, 17, 23 }; { 3, 7, 19, 23 }; { 7, 11, 17, 29 }; { 5, 11, 19, 29 }; { 3, 13, 19, 29 }; { 7, 13, 23, 29 }; { 5, 11, 17, 31 }; { 3, 13, 17, 31 }; { 7, 11, 19, 31 }; { 3, 11, 23, 31 }; { 5, 13, 23, 31 }; { 5, 7, 29, 31 }; { 17, 19, 29, 31 }; { 7, 11, 37, 41 }; { 17, 29, 37, 41 }; { 19, 31, 37, 41 }; { 5, 11, 37, 43 }; { 3, 13, 37, 43 }; { 19, 29, 37, 43 }; { 17, 31, 37, 43 }; { 5, 7, 41, 43 }; { 17, 19, 41, 43 }; { 29, 31, 41, 43 }; { 7, 13, 37, 47 }; { 23, 29, 37, 47 }; { 3, 5, 41, 47 }; { 11, 13, 41, 47 }; { 17, 23, 41, 47 }; { 3, 7, 43, 47 }; { 19, 23, 43, 47 }; ....

    For five primes, again not all can be odd, so one has to be 2. But there are still a lot of ways it can happen (based on brute force search).

    Not sure if this helps your intuition.