BETA

Difficulty Level: Basic

Submissions: 97 Accuracy:

44.33%

[Numbers having alternate bits in range 1 to n]
     

Given a positive integer n. The problem is to print the numbers in the range 1 to n having bits in alternate pattern. Here alternate pattern means that the set and unset bits in the number occur in alternate order. For example- 5 has an alternate pattern i.e. 101.

INPUT: The first line consists of an integer T i.e. the number of test cases. Each test case has the single line input, denoting the integer n.

OUTPUT: Print all the numbers with alternate bits in the range 1 to n.

CONSTRAINTS:
1<=T<=100
1<=n<=105

EXAMPLES:
INPUT :

2
10
50

OUTPUT : 
1 2 5 10
1 2 5 10 21 42

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

Author: saksham0751

Set Default Code

					   
It is recommended to 'Compile & Test' your code before clicking 'Submit'!

Compilation/Execution Result:

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