Representation of any positive integer as a series $2^{n_1}-2^{n_2}+2^{n_3}-2^{n_4}+\cdots\,$?

44 Views Asked by At

Essentially the title: a friend stumbled upon this the other day, and we can't find anything on the internet about it. The $n_k$s are all distinct positive integers.

As an example:

$$45 = 2^6-2^5+2^4-2^2+2^0$$

A definition of this as a series, proof of it, or any relevant literature/wiki articles would be appreciated.

2

There are 2 best solutions below

1
On

This is just reading off the strings of 1s in the binary representation of your integer.

In your example, $$ 45_{10}=101101_{2}=\underbrace{2^5}_{=2^6-2^5}+\underbrace{2^3+2^2}_{=2^4-2^2}+2^0. $$

0
On

You can do this by a form of induction. Suppose there is an expression of this form for every integer up to $2^m$ and let $2^{m+1}\ge n \gt 2^m$ then $$n=2^{m+1}-(2^{m+1}-n)$$ and we have $2^{m+1}-n=r\le 2^m$

Well we can express $r$ in the required form and when it is subtracted from $2^{m+1}$ all the signs change of the lower powers change so they alternate.

I'll leave you to complete the details.