Binary Flip
Statement
Goal
The goal is to flip all bits of a number.Do not flip leading zeros.
Example :
You have 9.
Then the binary number is 1001.
If we reverse all bits, we obtain 0110.
So 0110 is 6.
The answer is 6.
Input
Line 1 : An integer n. It's the number to convert.
Output
Line 1 : The converted number
Constraints
n is a positive number.
Example
Input
9
Output
6
Game modes
Fastest, Shortest
Test cases
Example Test
Input
9
Output
6
Example Validator
Input
26
Output
5
< 2 bits Test
Input
2
Output
1
< 2 bits Validator
Input
1
Output
0
< 5 bits Test
Input
22
Output
9
< 5 bits Validator
Input
19
Output
12
< 10 bits Test
Input
583
Output
440
< 10 bits Validator
Input
856
Output
167
Power of 2 Test
Input
64
Output
63
Power of 2 Validator
Input
128
Output
127
A big number Test
Input
1874587458
Output
272896189
A big number Validator
Input
1501425233
Output
646058414
Solution language
Solution
Stub generator input