The set X consists of the nonempty subsets S of {1, 2, ..., n} that have an integer average.

A good period-2 function is

S={a1, a2, ..., ak} -> f(S)={n+1 - a1, n+1 - a2, ..., n+1 - ak}
(that is, associate to S the set obtained by subtracting from n+1 the elements of S).

This operation maps X into itself, and has period two!


By the previous discussion, this reduces our problem to "counting" the subsets S of {1, 2, ..., n} that are in X, and satisfy f(S)=S.

Q: Can you describe these sets?
[It makes a difference whether n is odd or even! You can try to experiment with small values of n.]

In one of the cases, there are many such sets.
Try again to form pairs! One of them has no pair, so the total number of elements was odd.