Back with a bang

Our hero Batman likes to play with coins. He has n n number of coins all of which are white on one side and black on the other. He puts all the coins on a straight line with white side up. Now he starts to flip the coins. First he flips every coins placed at position of multiple of 1 1 , then at multiple of 2 2 and so on till the multiple of n n . He wants you to guess the last position of the coin whose black side is up if n n is given to be 1000000007 .


The answer is 999950884.

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.

1 solution

Answer of this question is ( n ) 2 \left( \left\lfloor \sqrt { n } \right\rfloor \right) ^{ 2 } . Now let me explain why.

A coin at i t h i^{th} place is flipped each time when flipping is done for the multiple of divisors of i i .

\because Starting color is white and Ending color is black.

\therefore No. of flipping should be odd.

Which means number of divisors of i i should be odd so that coin at i t h i^{th} position is black. Therefore, i is a perfect square and the last perfect square number is our solution which is ( n ) 2 \left( \left\lfloor \sqrt { n } \right\rfloor \right) ^{ 2 } .

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...