Number is sparse or not
Submissions: 3580   Accuracy:

61.5%

  Difficulty: Basic   Marks: 1
     

Given a number, check whether it is sparse or not. A number is said to be a sparse number if in binary representation of the number no two or more consecutive bits are set.

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 '1' if the number is sparse and '0' if the number is not sparse.

Constraints:
1 <=T<= 100
1 <=n<= 100

Example:
Input:
2
2
3

Output:
1
0

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

Author: Yash Goel


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

to report an issue on this page.