내용 |
Number Complement
The complement of a number is defined here as the number's bitwise inversion from its highest-order 1-bit through its lowest-order bit. For example, the number n=5 is represented as 00000101 in binary. The binary complement of n is 010, which is 2 in decimal notation.
Complete the getIntegerComplement function in your editor. It has one parameter: a base-10 integer, n. This function must return the complement of n as a base-10 integer.
Input Format
Locked stub code in the editor reads a single integer, n from stdin and passes it to the function.
constraints.
. 0 <= n <= pow(10, 5)
Output Format
Return an integer denoting the complement of n.
Sample Input 0
50
Sample Output 0
13
Explanation 0
(50)base-10 converts to (110010)base-2. When we invert each bit in the sequence we get (001101)base-2, witch equals (13)base-10. Thus, we return 13.
Sample Input 1
100
Sample Output 1
27
|