Sum vs XOR

  • + 0 comments

    Python

    def sumXor(n):
        count = 1
        while n != 0:
            if n % 2 == 0:
                count *= 2
            n >>= 1
        return count