TITLE: Sum of powers of four
QUESTION [5 upvotes]: Let $0\leq a_1\leq a_2\leq\dots\leq a_n\leq b$ be integers such that $4^b\leq 4^{a_1}+\dots+4^{a_n}$. Can $4^b$ always be written as a sum of some subset of $4^{a_1},\dots,4^{a_n}$?
I think it might be possible to perform some sort of greedy algorithm, where we collect four identical powers of $4$, whenever such exist, into a greater power of $4$. We can perform this process starting from the smallest power of $4$ until it is no longer possible, so we end up with at most three powers of $4$ for each power.

REPLY [3 votes]: By induction on $b\geq 0$. The basic step is trivial.
For $b>1$, assume that the statement is true for $b-1$. We have two cases.
i) $a_1\geq 1$ then take $A_i=a_i-1$, by the the inductive step $4^{b-1}$ can be written as a sum of some subset of $4^{A_1},\dots,4^{A_n}$ and then by multiplying by $4$ we get a representation of $4^{b}$.
ii) Assume that $a_1=\dots=a_r=0$ and $a_{r+1}\geq 1$ and assume  that $4^{b-1}$ can not  be written as a sum of some subset of $4^{A_{r+1}},\dots,4^{A_n}$ (otherwise we ara done as in i)). 
This means that
$$4^{b-1}> 4^{A_{r+1}}+\dots+4^{A_n}\quad \Rightarrow \quad
4^{b}> 4^{a_{r+1}}+\dots+4^{a_n}.$$
But we know that $4^{b}\leq r+4^{a_{r+1}}+\dots+4^{a_n}$. Hence 
$$4^{b}=4^{a_{1}}+\dots+4^{a_j}+4^{a_{r+1}}+\dots+4^{a_n}$$
where $1\leq j=4^{b}-(4^{a_{r+1}}+\dots+4^{a_n})\leq r$.
P.S. This approach gives you also a recursive algorithm which generate such representations.