Defining $y^2$ in sums of $2^x$

62 Views Asked by At

Is there an expression which defines $y^2$ with $y \in \mathbb{N}$ into as little as possible sums of $2^x$ where $x \in \mathbb{N}_0$?

i.e.

$1^2 = 2^0$

$2^2 = 4 = 2^2$

$3^2 = 9 = 2^3 + 2^0$

$4^2 = 16 = 2^4$

$5^2 = 25 = 2^4 + 2^3 + 2^0$

$6^2 = 36 = 2^5 + 2^2$

$7^2 = 49 = 2^5 + 2^4 + 2^0$

$8^2 = 64 = 2^6$

$9^2 = 81 = 2^6 + 2^4 + 2^0$

$10^2 = 100 = 2^6 + 2^5 + 2^2$

$11^2 = 121 = 2^6 + 2^5 + 2^4 + 2^3 + 2^0$

$12^2 = 144 = 2^7 + 2^4$

$13^2 = 169 = 2^7 + 2^5 + 2^3 + 2^0$

$14^2 = 196 = 2^7 + 2^6 + 2^2$

$15^2 = 225 = 2^7 + 2^6 + 2^5 + 2^0$

$16^2 = 256 = 2^8$

$17^2 = 289 = 2^8 + 2^5 + 2^0$

$18^2 = 324 = 2^8 + 2^6 + 2^2$

$19^2 = 361 = 2^8 + 2^6 + 2^5 + 2^3 + 2^0$

$20^2 = 400 = 2^8 + 2^7 + 2^4$

1

There are 1 best solutions below

0
On

To any natural $m$ you associate the sequence

$$p_n:=\lfloor m\,2^{-n}\rfloor\bmod2,$$ where the term $p_n$ indicates if the power $2^n$ belongs to the sum (as of $2^n>m, p_n=0$).

E.g. $25\to1,0,0,1,1,0,0,0,0,0,\cdots\equiv 2^0+2^3+2^4$.


I don't know of a direct formula that would give the number of terms, nor the powers of these terms.

Update:

The number of terms is known as the Hamming weight of the number.