Generalized representation for a sum of powers of 2 to represent a number

Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
Lets say there is positive number $n = 118$, which we want to represent as sum of powers of i.e. $2^k$ (while $n$ being always $>= 0$).
Following the repetitive division by powers of 2, we obtain that $n$ can be written as the sum of following powers of $2$:
$118$ = $2^6$ + $2^5$ + $2^4$ + $2^2$ + $2^1$
On the other hand, the solution $(sum_i=0^6 2^i = 127)$ is greater than $118$. My question is: how can we generalize this descending pattern of powers, through which we will know that we have to exclude $2^3$ and $2^0$ from the sum? Thanks.
number-theory elementary-number-theory power-series
add a comment |Â
up vote
0
down vote
favorite
Lets say there is positive number $n = 118$, which we want to represent as sum of powers of i.e. $2^k$ (while $n$ being always $>= 0$).
Following the repetitive division by powers of 2, we obtain that $n$ can be written as the sum of following powers of $2$:
$118$ = $2^6$ + $2^5$ + $2^4$ + $2^2$ + $2^1$
On the other hand, the solution $(sum_i=0^6 2^i = 127)$ is greater than $118$. My question is: how can we generalize this descending pattern of powers, through which we will know that we have to exclude $2^3$ and $2^0$ from the sum? Thanks.
number-theory elementary-number-theory power-series
Isn't $i = 0$?.
â Enigsis
Sep 3 at 8:05
The sum should start from $i = 0$ so what we should do is to exclude $2^0$ and $2^3$. Otherwise, if the sum starts from $i = 1$, the result should be $126$.
â ArsenBerk
Sep 3 at 8:05
True. Let me correct.
â khan
Sep 3 at 8:06
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
Lets say there is positive number $n = 118$, which we want to represent as sum of powers of i.e. $2^k$ (while $n$ being always $>= 0$).
Following the repetitive division by powers of 2, we obtain that $n$ can be written as the sum of following powers of $2$:
$118$ = $2^6$ + $2^5$ + $2^4$ + $2^2$ + $2^1$
On the other hand, the solution $(sum_i=0^6 2^i = 127)$ is greater than $118$. My question is: how can we generalize this descending pattern of powers, through which we will know that we have to exclude $2^3$ and $2^0$ from the sum? Thanks.
number-theory elementary-number-theory power-series
Lets say there is positive number $n = 118$, which we want to represent as sum of powers of i.e. $2^k$ (while $n$ being always $>= 0$).
Following the repetitive division by powers of 2, we obtain that $n$ can be written as the sum of following powers of $2$:
$118$ = $2^6$ + $2^5$ + $2^4$ + $2^2$ + $2^1$
On the other hand, the solution $(sum_i=0^6 2^i = 127)$ is greater than $118$. My question is: how can we generalize this descending pattern of powers, through which we will know that we have to exclude $2^3$ and $2^0$ from the sum? Thanks.
number-theory elementary-number-theory power-series
number-theory elementary-number-theory power-series
edited Sep 3 at 8:14
asked Sep 3 at 7:57
khan
1337
1337
Isn't $i = 0$?.
â Enigsis
Sep 3 at 8:05
The sum should start from $i = 0$ so what we should do is to exclude $2^0$ and $2^3$. Otherwise, if the sum starts from $i = 1$, the result should be $126$.
â ArsenBerk
Sep 3 at 8:05
True. Let me correct.
â khan
Sep 3 at 8:06
add a comment |Â
Isn't $i = 0$?.
â Enigsis
Sep 3 at 8:05
The sum should start from $i = 0$ so what we should do is to exclude $2^0$ and $2^3$. Otherwise, if the sum starts from $i = 1$, the result should be $126$.
â ArsenBerk
Sep 3 at 8:05
True. Let me correct.
â khan
Sep 3 at 8:06
Isn't $i = 0$?.
â Enigsis
Sep 3 at 8:05
Isn't $i = 0$?.
â Enigsis
Sep 3 at 8:05
The sum should start from $i = 0$ so what we should do is to exclude $2^0$ and $2^3$. Otherwise, if the sum starts from $i = 1$, the result should be $126$.
â ArsenBerk
Sep 3 at 8:05
The sum should start from $i = 0$ so what we should do is to exclude $2^0$ and $2^3$. Otherwise, if the sum starts from $i = 1$, the result should be $126$.
â ArsenBerk
Sep 3 at 8:05
True. Let me correct.
â khan
Sep 3 at 8:06
True. Let me correct.
â khan
Sep 3 at 8:06
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
0
down vote
Well, I can think of $2$ ways to do that:
1) We can represent the number in base $2$. When we do that, whenever we have a $0$ in base $2$ representation, corresponding power should be excluded.
For example, $118 = (1110110)_2$ so we should exclude $2^0$ and $2^3$.
2) This one is more like an algorithm. Let our number be $n$. Then, first we find smallest number $k$ such that $2^k - 1 ge n$. Then we find the difference $d = (2^k - 1) - n$ and express it by using powers of $2$. While doing this, we should find largest $m$ such that $2^m <= d$. Then do the same for $d - 2^m$ and continue this until $d = 0$. The $m$ values you find during this process will be the excluded powers.
For example, we have $n = 118$. Smallest number $k$ such that $2^k - 1 > n$ is $k = 7$ so we have $d = 9$. Then the largest $m$ such that $2^m le d$ is $m = 3$. So our new $d$ is $9-2^3 = 1$. Then the largest $m$ such that $2^m le d$ is $m = 0$ and our new difference is $0$ so we are done by excluding $2^3$ and $2^0$.
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
Well, I can think of $2$ ways to do that:
1) We can represent the number in base $2$. When we do that, whenever we have a $0$ in base $2$ representation, corresponding power should be excluded.
For example, $118 = (1110110)_2$ so we should exclude $2^0$ and $2^3$.
2) This one is more like an algorithm. Let our number be $n$. Then, first we find smallest number $k$ such that $2^k - 1 ge n$. Then we find the difference $d = (2^k - 1) - n$ and express it by using powers of $2$. While doing this, we should find largest $m$ such that $2^m <= d$. Then do the same for $d - 2^m$ and continue this until $d = 0$. The $m$ values you find during this process will be the excluded powers.
For example, we have $n = 118$. Smallest number $k$ such that $2^k - 1 > n$ is $k = 7$ so we have $d = 9$. Then the largest $m$ such that $2^m le d$ is $m = 3$. So our new $d$ is $9-2^3 = 1$. Then the largest $m$ such that $2^m le d$ is $m = 0$ and our new difference is $0$ so we are done by excluding $2^3$ and $2^0$.
add a comment |Â
up vote
0
down vote
Well, I can think of $2$ ways to do that:
1) We can represent the number in base $2$. When we do that, whenever we have a $0$ in base $2$ representation, corresponding power should be excluded.
For example, $118 = (1110110)_2$ so we should exclude $2^0$ and $2^3$.
2) This one is more like an algorithm. Let our number be $n$. Then, first we find smallest number $k$ such that $2^k - 1 ge n$. Then we find the difference $d = (2^k - 1) - n$ and express it by using powers of $2$. While doing this, we should find largest $m$ such that $2^m <= d$. Then do the same for $d - 2^m$ and continue this until $d = 0$. The $m$ values you find during this process will be the excluded powers.
For example, we have $n = 118$. Smallest number $k$ such that $2^k - 1 > n$ is $k = 7$ so we have $d = 9$. Then the largest $m$ such that $2^m le d$ is $m = 3$. So our new $d$ is $9-2^3 = 1$. Then the largest $m$ such that $2^m le d$ is $m = 0$ and our new difference is $0$ so we are done by excluding $2^3$ and $2^0$.
add a comment |Â
up vote
0
down vote
up vote
0
down vote
Well, I can think of $2$ ways to do that:
1) We can represent the number in base $2$. When we do that, whenever we have a $0$ in base $2$ representation, corresponding power should be excluded.
For example, $118 = (1110110)_2$ so we should exclude $2^0$ and $2^3$.
2) This one is more like an algorithm. Let our number be $n$. Then, first we find smallest number $k$ such that $2^k - 1 ge n$. Then we find the difference $d = (2^k - 1) - n$ and express it by using powers of $2$. While doing this, we should find largest $m$ such that $2^m <= d$. Then do the same for $d - 2^m$ and continue this until $d = 0$. The $m$ values you find during this process will be the excluded powers.
For example, we have $n = 118$. Smallest number $k$ such that $2^k - 1 > n$ is $k = 7$ so we have $d = 9$. Then the largest $m$ such that $2^m le d$ is $m = 3$. So our new $d$ is $9-2^3 = 1$. Then the largest $m$ such that $2^m le d$ is $m = 0$ and our new difference is $0$ so we are done by excluding $2^3$ and $2^0$.
Well, I can think of $2$ ways to do that:
1) We can represent the number in base $2$. When we do that, whenever we have a $0$ in base $2$ representation, corresponding power should be excluded.
For example, $118 = (1110110)_2$ so we should exclude $2^0$ and $2^3$.
2) This one is more like an algorithm. Let our number be $n$. Then, first we find smallest number $k$ such that $2^k - 1 ge n$. Then we find the difference $d = (2^k - 1) - n$ and express it by using powers of $2$. While doing this, we should find largest $m$ such that $2^m <= d$. Then do the same for $d - 2^m$ and continue this until $d = 0$. The $m$ values you find during this process will be the excluded powers.
For example, we have $n = 118$. Smallest number $k$ such that $2^k - 1 > n$ is $k = 7$ so we have $d = 9$. Then the largest $m$ such that $2^m le d$ is $m = 3$. So our new $d$ is $9-2^3 = 1$. Then the largest $m$ such that $2^m le d$ is $m = 0$ and our new difference is $0$ so we are done by excluding $2^3$ and $2^0$.
answered Sep 3 at 8:23
ArsenBerk
6,9521933
6,9521933
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f2903630%2fgeneralized-representation-for-a-sum-of-powers-of-2-to-represent-a-number%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Isn't $i = 0$?.
â Enigsis
Sep 3 at 8:05
The sum should start from $i = 0$ so what we should do is to exclude $2^0$ and $2^3$. Otherwise, if the sum starts from $i = 1$, the result should be $126$.
â ArsenBerk
Sep 3 at 8:05
True. Let me correct.
â khan
Sep 3 at 8:06