• + 1 comment

    Here is my Python solution! A really clever trick is to realize that the amount is just 2 raised to the amount of 0s in the binary representation of the number.

    def sumXor(n):
        if n == 0:
            return 1
        return 2 ** (bin(n).count("0") - 1)