Let $S$ be a finite set of $n$ elements. There are $2^n$ subsets of $S$. I want to index them by an integer in some simple way. That is, I want to find a mapping $I:\mathbb{N}\rightarrow \mathbb{P}(S)$, whose domain is the integers from 0 to $2^n - 1$, and whose image are all the subsets of $S$. The notation $\mathbb{P}(S)$ stands for the power set of $S$.
One simple way to do it is to use binary notation. The drawback is that very large indices (like 10000....00) may refer to subsets with very few elements. I want instead that the subsets are ordered according to their cardinality. Also, the indexing function $I$ should be easy to compute and invert.
I haven't gotten very far, but here's what I've noticed. There are $\binom{n}{j}$ subsets with $j$ elements. If $i$ is an index and
$$\sum_{j=0}^k \binom{n}{j} \le i < \sum_{j=0}^{k+1} \binom{n}{j}$$
we could arrange things so that $i$ index subsets with $k$ elements. But I'm stuck here, because there is no closed formula for a partial sum of binomials.