I heard a long time ago that any integer can be expressed as sums (or differences) of powers of three, using each power only once. Examples:
$5=9-3-1$
$6=9-3$
$22=27-9+3+1$
etc.
To my surprise, I couldn't find anything about this on the Internet. So..
- Is this true? (So far I couldn't find any integer I can't express like this)
- Is there a proof to it?
- (Kind of a side question, assuming this is true): Is there a formula that gives the coefficients (-1, 0 or 1) for each power for a given integer?
Thanks
This system is well-known and is called balanced ternary. It generalizes to all odd bases, but instead of the digits $-1,0$, and $1$, for base $2n+1$ you have the digits $0,\pm 1,\ldots,\pm n$; you can read a bit more here (with further generalizations in the rest of that article) and in this question and answer.