Minimum number of partitions required for obtaining all numbers from $1$ to $n$ I took part in a coding contest organized by a club in my college for freshers, In one of the problems it was asked to find out the minimum number of partitions of a number $n$, so that all the integers from $1$ to $n$ can be formed such that the partitions are minimum. For such a problem, I couldn't find anything in searching, and I don't know what to search exactly.
The solution is not satisfactory to me at all, in short, it uses the fact that Strong Induction Proof: Every natural number = sum of distinct powers of 2 and then eerily uses $(7)_{10} = (111)_2$ as an example, saying, from $1, 2, 4$ we can make all integers till $7$, which is true. But this just added more to my confusion.
At the beginning, I got confused with binary representation and since the question on which the answer is based, I couldn't refrain from asking Why not base 3? (I got the answer: because base 3 won't have distinct powers, so it won't be minimum) (1)
Since it is hard to check for even a small test cases, I wrote a program to get more insights, and indeed, minimum number of partitions are the digits in binary representation of $n$, and that the numbers seem arbitrary. Therefore, I think that there might be some link to base $2$, but the way it is being used and explained to me by my peers and seniors might be incorrect.
My approach:
We could use generating function for an arbitrary number of partitions say $k$,  (2)
so the generation function would be:
$$ (1 + x^{p_1})(1 + x^{p_2})\cdots(1 + x^{p_k}) = 1 + a_1x + a_2x^2+\ldots+a_kx^k$$
where each $p_i$ is the $i^{\text{th}}$ number and $p_1 + p_2 +\ldots+p_k = n$
If we somehow proof that each $a_i > 0$, and then find the minimum condition, we'll be done.
on solving the expression, Differentiation can be hectic, if try to find a pattern by expanding it comes out to be
$$ 1 + \sum_{i = 1}^kx^{p_i} + \sum_{i,j = 1}^kx^{p_i + p_j} + \ldots + x^{p_1 + p_2 +\ldots+p_k}$$
...which doesn't give any lead. And of course, numbers can  repeat, which can be even more problematic.
Hence, I'm stuck at the very beginning itself.

My questions are:

*

*There is obviously some link to powers of $2$, but why? and why only $2$?

*would my approach (finding a pattern first, then trying to find the minimum condition) actually work?


Some partitions that satisfy the conditions:
$\begin{align} 8 &= 4 + 2 + 1 + 1 \\ &= 3 + 3 + 1 + 1\\ &= 3 + 2 + 2 + 1 \end{align}$
$ \begin{align} 9 &= 5 +2 +1+ 1\\ 
&=4 +3 +1 +1 \\
&=4+ 2+ 2+ 1\\ 
&=3 +3+ 2+ 1 \end{align}$
$\begin{align} 14 &= 7+4+2+1 \end{align}$
Note: I know minimum partitions are $\lfloor \log_2(n) \rfloor + 1$, I want to know HOW.
 A: Let's say your number $n$ is between $2^{k-1}$ and $2^k-1$.
On one hand, you can make the partition of size $k$. This can be proven by induction on $k$. Namely, $k=1$ means $n=1$, which is its own partition of size $1$. The inductive step (sketch): "halve" $n$, i.e. take $m=\lceil n/2\rceil$, which gives $n-m=\lfloor n/2\rfloor$; prove that $2^{k-2}\le n-m\le 2^{k-1}-1$. Then, partition $n-m$ into a partition with $k-1$ terms (as per inductive hypothesis) and add $m$ to that partition to get a partition of $n$ into $k$ terms. Prove you can now make all the sums from $1$ to $n$.
(This logic can be easily turned into a simple iterative algorirhm, by the way.)
On the other hand, you cannot make a shorter partition. Imagine you had a partition with $l$ terms, where $l\lt k$. How many different sums would you be able to make out of those terms? Each term can be either added to the sum or not, so it is at most $2^l$ sums (some sums may be equal!), however we don't want the "empty" sum (no terms chosen), so in effect you can have at most $2^l-1\le 2^{k-1}-1\lt 2^{k-1}\le n$ sums, i.e. you cannot possibly cover all numbers from $1$ to $n$.
The last part is, for me, providing the intuition for "why powers of $2$?" . Namely, if the number of terms in your partition is too small, you just cannot recreate all the sums you want. The powers of $2$ naturally arise when you try to count the number of different sums you can make, simply because, for every term in your partition, you have exactly two choices: you can either put the term into the sum - or not!
