Set the rightmost unset bit
Submissions: 605   Accuracy:

46.93%

  Difficulty: Basic   Marks: 1

Given a non-negative number n. The problem is to set the rightmost unset bit in the binary representation of n. If there are no unset bits, then just leave the number as it is.

Input:
The first line of the input contains an integer T denoting number of test cases. Each of the following T lines will contain an integer N

Output:
For each of the test case print the required answer.

Constraints:
1<=T<=3.4*10^3
1<=N<=5*10^4

Example:
Input

5
6
10
11
19
20
Output
7
11
15
23
21

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

Author: ShivamKD


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.