Friday, 20 May 2016

Challenge #2


Mr. Algorithm have an integer number, which he want to reverse by following steps:
  1. Convert the number into binary string.
  2. Reverse binary string.
  3. Convert the reversed binary string back to integer.
Can you help him write a function to do it ?

For x = 234, the output should be
ReverseBit(x) = 87.
23410 = 111010102 => 010101112 = 8710.
  • [input] integer x
    A non-negative integer.
  • [output] integer
    x reversed as described above.

    If you want, you can check my solution for only 1 euro! (check PayPal button below):


No comments:
Write comments