Next sparse binary number
Submissions: 1803   Accuracy:

43.45%

  Difficulty: Easy   Marks: 2

Given an integer n in the input, find its next sparse binary number.A sparse binary number is a number whose binary representation does not contain any consecutive 1s.

Input:

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

Output:

Print next Sparse binary number,if the input number is not sparse else print the number itself.

Constraints:
1 ≤ T ≤ 100
1 ≤ n ≤ 100000

Example:

Input
2
3
5

Output
4
5

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

Author: rajatjha


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.