Powers of 2

Define f ( n ) f(n) to be equal to the greatest power of 2 2 that n n is divisible by. For instance, f ( 5 ) = 1 f(5)=1 and f ( 12 ) = 4 f(12)=4 . If f ( 1 ) + f ( 2 ) + + f ( n ) = 1000 f(1)+f(2)+\cdots+f(n)=1000 , find n n .

Source: AoPS


The answer is 244.

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.

2 solutions

Chew-Seong Cheong
Aug 21, 2015

Let the sum of f ( n ) f(n) be S S . We note that every n n contributes at least 1 1 to S S , if n n a multiple of 2 2 it contributes an extra 1 1 , a multiple of 4 4 , extra 2 2 , ... a multiple of of 2 k 2^k contributes an extra 2 k 1 2^{k-1} to S S . Therefore, S S is given by:

S ( n ) = i = 1 n f ( i ) = n + n 2 + 2 n 4 + 4 n 8 + . . . S ( n ) = n + j = 1 m ( ( 2 j 2 j 1 ) n 2 j ) \begin{aligned} S(n) & = \sum_{i=1}^n f(i) \\ & = n + \left \lfloor \frac{n}{2} \right \rfloor + 2 \left \lfloor \frac{n}{4} \right \rfloor + 4 \left \lfloor \frac{n}{8} \right \rfloor + ... \\ \Rightarrow S(n) & = n + \sum_{j=1}^m \left(\left(2^j-2^{j-1}\right) \left \lfloor \frac{n}{2^j} \right \rfloor \right) \end{aligned}

For a power of 2 2 , n = 2 k n=2^k :

S ( 2 k ) = 2 k + 2 k 2 + 2 2 k 4 + 4 2 k 8 + . . . + 2 k 1 2 k 2 k = 2 k + 2 k 1 + 2 k 1 + 2 k 1 + . . . + 2 k 1 = ( k + 2 ) 2 k 1 \begin{aligned}\Rightarrow S(2^k) & = 2^k + \left \lfloor \frac{2^k}{2} \right \rfloor + 2 \left \lfloor \frac{2^k}{4} \right \rfloor + 4 \left \lfloor \frac{2^k}{8} \right \rfloor + ... + 2^{k-1} \left \lfloor \frac{2^k}{2^k} \right \rfloor \\ & = 2^k + 2^{k-1} + 2^{k-1} + 2^{k-1} + ... + 2^{k-1} \\ & = (k+2)2^{k-1} \end{aligned}

Since S ( 2 7 ) = 576 < 1000 < S ( 2 8 ) = 1280 2 7 = 128 < n < 2 8 = 256 S(2^7) = 576 < 1000 < S(2^8) = 1280 \quad \Rightarrow 2^7 = 128 < n < 2^8 = 256 .

Estimate n = 1280 256 × 1000 = 200 n = \dfrac{1280}{256}\times 1000 = 200

\(\begin{array} {} S(200) = 200 + 100 + 2(50)+4(25)+8(12)+16(6)+32(3)+64(1) = 852 \\ S(240) = 240 + 120 + 120 +120+120+112+96+64 = 992 \\ S(244) = 244 + 122 + 122 +120+120+112+96+64 = 1000 \end{array} \)

Therefore, n = 244 n = \boxed{244}

FURTHER SOLUTION \color{#3D99F6}{\text{FURTHER SOLUTION}}

All S ( n ) S(n) can be expressed as a sum of S ( 2 k ) S(2^k) as follows:

S ( n ) = b 0 S ( 2 0 ) + b 1 S ( 2 1 ) + b 3 S ( 2 3 ) + . . . + b m S ( 2 m ) = k = 0 m b k S ( 2 k ) = k = 0 m b k ( k + 2 ) 2 k 1 \begin{aligned} \quad \quad S(n) & = b_0 S(2^0) + b_1 S(2^1) + b_3 S(2^3) + ... + b_m S(2^m) \\ & = \sum_{k=0}^m b_kS(2^k) \\ & = \sum_{k=0}^m b_k (k+2)2^{k-1} \end{aligned}

where b k = 0 b_k = 0 or 1 1 is a unit function or binary digit.

Then n n is given by:

n 10 = ( b m . . . b 2 b 1 b 0 ) 2 = b 0 2 0 + b 1 2 1 + b 2 2 2 + . . . + b m 2 m = k = 0 m b k 2 k \begin{aligned} \quad \quad n_{10} & = (\overline{b_m...b_2b_1b_0})_2 \\ & = b_02^0 + b_12^1 + b_22^2 +...+ b_m2^m \\ & = \sum_{k=0}^m b_k 2^k \end{aligned}

For S ( n ) = 1000 S(n) = 1000 ,

S ( n ) = 1000 = 576 + 256 + 112 + 48 + 8 = S ( 2 7 ) + S ( 2 6 ) + S ( 2 5 ) + S ( 2 4 ) + S ( 2 2 ) n 10 = 1111010 0 2 = 128 + 64 + 32 + 16 + 4 = 244 \begin{aligned} \quad \quad S(n) & = 1000 \\ & = 576 + 256 + 112 + 48 + 8 \\ & = S(2^7) + S(2^6) + S(2^5) +S(2^4) +S(2^2) \\ \Rightarrow n_{10} & = 11110100_2 \\ & = 128 + 64+32+16+4 \\ & = \boxed{244} \end{aligned}

Moderator note:

Great! This does eventually involve some extent of trial and error, though one can minimize it with proper bounding approach.

In fact, we can build this function up iteratively through looking at the powers of 2. If k < 2 n k < 2^n , what is the relationship between f ( k ) , f ( 2 n + k ) , f ( 2 n ) f(k), f(2^n + k ), f ( 2^n) ?

Great! This does eventually involve some extent of trial and error, though one can minimize it with proper bounding approach.

In fact, we can build this function up iteratively through looking at the powers of 2. If k < 2 n k < 2^n , what is the relationship between f ( k ) , f ( 2 n + k ) , f ( 2 n ) f(k), f(2^n + k ), f ( 2^n) ?

Calvin Lin Staff - 5 years, 9 months ago
Bill Bell
Jul 7, 2015

Construct the function f f from the prime factor decompositions of successive natural numbers, where possible. Then accumulate these values until 1000 is achieved.

But we don't need the full prime factor decomposition, just the greatest power of two! Here's a more economical way of getting the result.

U r meant to do it mathematically. It is quite easy to do this through a computer program.

Shubham Bhargava - 5 years, 9 months ago

Log in to reply

I am not interested in how I am 'meant' to do it. I am interested in exploring for my own benefit. FYI, there is lots to learn about writing software in doing the problems on brilliant. You can do them in some easy way or you can try to learn from them.

Bill Bell - 5 years, 9 months ago

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...