What is meant with "whose xor-sum is n"?

44 Views Asked by At

A sequence look-up led me to sequence A088512 in OEIS.org with description "Number of partitions of n into two parts whose xor-sum is n."

I know the "Number of partitions of n into two parts" which is Stirling2[n,2], but I don't understand the last part of the sentence, especially in relation to number of partitions.

EDIT: (This explains the confusion. I was thinking about set partitions instead of a simple number partition.)

1

There are 1 best solutions below

1
On

The link to the aforementioned sequence

Consider the case for $n=7$. We can split it into $1+6$, $2+5$, $3+4$ where $1 \oplus 6 = 2 \oplus 5 = 3 \oplus 4 = 7$. Here, $\oplus$ stands for exclusive-or.

Since there are $3$ such partitions for $7$, its value is $3$.

This can be calculated using the python code:

import math
def f(n):
    count = 0
    for i in range(1, math.ceil(n/2.0)):
        if i ^ (n - i) == n: count += 1
    return count

for n in range(10):
    print(n, f(n))