Which numbers were used in this sum ?

Suppose
2 a 1 + 2 a 2 + 2 a 3 + + 2 a n = 1627622 2^{a_1} + 2^{a_2} + 2^{a_3} + \ldots + 2^{a_n} = 1627622
where a 1 , a 2 , a 3 , , a n a_1 , a_2 , a_3 , \ldots , a_n are distinct positive integers.

What is the value of ( a 1 + a 2 + a 3 + + a n ) + n ( a_1 + a_2 + a_3 + \ldots + a_n ) + n ?


The answer is 131.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

5 solutions

converting 1627622 to binary 110001101010111100110 , now expanding this binary form in powers of 2 , we get it in same form as given question where
a1 =20
a2 =19
a3 =15
a4 =14
a5 =12
a6 = 10
a7 = 8
a8 = 7
a9 = 6
a10 = 5
a11 = 2
a12 = 1
hence ΣAn + n = 119 + 12 = 131


Avi Aryan
Jun 6, 2014

We observe that ( 2 1 + 2 2 + 2 3 . . . 2 n 1 ) + 2 = 2 n ( 2^1 + 2^2 + 2^3 ... 2^{n-1} ) + 2 = 2^{n} .
Thus 2 n 2^{n} is more than sum of 2's of all powers less than n n .
Here 2 a x 2^{a_x} where a x a_x is maximum of all a a 's will be more than 1627622 2 \frac {1627622}{2} .

Now 2 21 = 2097152 2^{21} = 2097152 and 2 20 = 1048576 2^{20} = 1048576 . 2 21 2^{21} is more than the sum i.e. 1627622 1627622 but 2 20 2^{20} is the maximum power of 2 less than the sum .

So there exists some a x = 20 a_x = 20 for x in 1 to n .

Now we know 2 20 2^{20} exists so we will minus that.
1627622 1048576 = 579046 1627622 - 1048576 = 579046

Similarly now we will check the max power of 2 that can be accommodated in 579046 579046 . It is 2 19 = 524288 2^{19} = 524288 .
Minus that.
Now we have 54758 54758 . The max power of 2 that can be accommodated is 2 15 = 32768 2^{15} = 32768 .
.....
The same process can continue and all powers of 2 that were used can be extracted.
In the sum 1627622 , the powers of 2 ( a x a_x ) that were used are -- 20 19 15 14 12 10 8 7 6 5 2 1 .

The n n is 12 and the sum of a x a_x where x = 1..12 x=1..12 is 119 .
So answer = 131

Here is the code in AutoHotkey which I wrote to solve this problem.

msgbox % getParams(l := 1627622, 0)
msgbox % z := getParams(l, 1)
f := 0
loop, parse, z, %A_Space%
    f+=A_LoopField+1
msgbox % f
return

getParams(sum, r=0){
    static a := 1
    while sum>0
        loop
        {
            a*=2
            if (a>sum)
            {
                a/=2,p.= (r ? Round(log(a)/log(2)) : Round(a)) " ",sum-=a,a:=1
                break
            }
        }
    return Substr(p,1,-1)
}
Alex Li
Feb 13, 2015
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
import java.util.ArrayList;
import java.util.List;
import java.util.Collections;
public class x
{
    public static void main(String[] args)
    {
        ArrayList<Integer> x = new ArrayList<Integer>();
        int i = 1627622;
        int k = 50;
        while(i>0)
        {
            if(Math.pow(2,k) <= i)
            {
                i-=Math.pow(2,k);
                x.add(k);
            }
            k--;
        }
        System.out.println(x);
    }
}

Adding, we get 20 + 19 + 15 + 14 + 12 + 10 + 8 + 7 + 6 + 5 + 2 + 1 + 12 = 131 20+19+15+14+12+10+8+7+6+5+2+1+12=\boxed{131}

Bilel Mabrouk
Jan 9, 2015

Here is my elegant C code to solve this problem :

int main(){    
    int x=1627622,i=0,s=0;
    int i=0;
    while (x!=0){
        i++;
        if (x%2==1)
            s+=i;
        x/=2;
    }
    printf("%d",s);
}

Explanation : We need to convert 1627622 to binary , then we have to count the sum of ones in its binary representation added to the sum of their positions in the representation , in other words : their powers . Since each time we find a one we add to our sum its position plus one for its presence : s+=i+1 , or we can , as I wrote in my code , initiate the first value of i to 0 and increment it as we enter the while loop , so the counting starts with 1.

Bill Bell
Oct 28, 2014

We are being asked to express this number as a sum of base two logarithms. It's easy to find that 2 22 { 2 }^{ 22 } exceeds the number. Therefore, what we need to do is to start with 2 22 { 2 }^{ 22 } and remove successively smaller powers of two, if present in the number, and noting their presence. Here is one possible way of doing that.

>>> indices = [ ]

>>> r=1627622

>>> for k in range ( 22, -1, -1 ) :

... term = 2 ** k

... if term < r :

... r -= term

... indices. append(k)

... elif term == r :

... indices.append(k)

... break

... else :

... pass

...

>>> indices

[20, 19, 15, 14, 12, 10, 8, 7, 6, 5, 2, 1]

>>> sum+len(indices)

131

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...