Swap all odd and even bits
Submissions: 2937   Accuracy:

73.08%

  Difficulty: Easy   Marks: 2
     

Given an unsigned integer N, swap all odd bits with even bits. For example, if the given number is 23 ( 0 0 0 1 0 1 1 1 ), it should be converted to 43 ( 0 0 1 0 1 0 1 1 ). Here every even position bit is swapped with adjacent bit on right side (even position bits are highlighted in binary representation of 23), and every odd position bit is swapped with adjacent on left side.

Input:

The first line of input contains an integer T denoting the number of test cases.
Then T test cases follow. The first line of each test case contains an integer N.

Output:

Corresponding to each test case, print in a new line, the converted number .

Constraints:

1 ≤ T ≤ 100
1 ≤ N ≤ 100

Example:

Input
2
23
2

Output
43
1

 

** For More Input/Output Examples Use 'Expected Output' option **

Author: rajatjha


Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.

to report an issue on this page.