1
$\begingroup$

Sorry for my math language and the question header; I'm not capable of the terms used for the mathematics to ask the question via text; so I had to use the example above; feel free to edit if you can keep the meaning the same.

So the question is like this: I know that the total is uniquely identifies the used exponential constants while using the base as $2$; like $2^x + 2^y = 129$ then the $x=0$ and $y=7$.

So I couldn't think of a function to get the values like $\operatorname{func}(129) = [0,7]$.

Thanks in advance. Note: I know it's dumb to ask that but help is appreciated.

  • 0
    @AndreaMori sorry for that(:2012-03-27

4 Answers 4

1

Hint $\ $ For naturals $\rm\:b>1,\ x < y,\:$ if $\rm\: n\: =\: b^{x} + b^{y} =\: b^x\: (1 + b^{y-x})\:$ then $\rm\:x\:$ is determined uniquely as the greatest power of $\rm\:b\:$ that divides $\rm\:n,\:$ and $\rm\:y\:$ is determined uniquely as $\rm\:x\:$ plus the greatest power of $\rm\:b\:$ that divides $\rm\:n/b^{x}-1.$

This is a special case of the existence and uniqueness of radix representation, which follows from that for the division algorithm (here repeated division by the radix $\rm b$).

4

If $x>0 ~\text{and}~y>0 $ then $2^x+2^y$ is an even number . Hence :

$(x,y)=\{(0,7),(7,0)\}$

  • 0
    I've asked for a function or a method to evaluate; your answer gives the how easy it is explanation; not the method but thanks.2012-03-27
2

I'm not sure what is actually the question, but the problem of writing a number $n\in\Bbb N$ as a sum of powers of $2$ is equivalent to finding its expression in base $2$.

  • 0
    As I told you, it is equivalent to find the expansion of n in base 2 and this is obtained by a repeated division by 2 keeping track of the remainders. For instance $129=2\cdot64+1$, $64=2\cdot32+0$, $32=2\cdot16+0$, $16=2\cdot8+0$, $8=2\cdot4+0$, $4=2\cdot2+0$, $2=2\cdot1+0$ and $1=2\cdot0+1$. Thus, $129=10000001$ (binary), i.e. $129=2^0+2^7$ because you have 1 only in the $0$-th and $7$-th place.2012-03-27
1

The function you are looking for is called dec2bin, when you are using Matlab. It would convert $129_{10}$ in decimal to $10000001_2$ in binary notation. As dec2base it works for other bases as well.

  • 0
    Thanks but I'll use it for programming, so no calculator included.2012-03-27