Set all odd bits
Submissions: 835   Accuracy:

58.7%

  Difficulty: Basic   Marks: 1

Given a number, the task is to set all odd bits of a number.

INPUT: The first line consists of an integer T i.e. the number of test cases. Each test case contains an integer n .

OUTPUT: For each test case, print the number formed after setting all the odd bits of the given number in newline.

CONSTRAINTS:

1<=T<=100
1<=n<=105

EXAMPLES:
INPUT :

2
20
10

OUTPUT : 
21
15

EXPLANATION:

Input : 20
Output : 21
Explanation : Binary representation of 20
is 10100. Setting all odd
bits make the number 10101 which is binary
representation of 21.

Input : 10
Output : 15

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

Contributor: S_A
Author: saksham0751


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



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


to report an issue on this page.