First and last Bit
Submissions: 801   Accuracy:

41.86%

  Difficulty: Basic   Marks: 1

Given a positive integer n. The problem is to check whether only the first and last bits are set in the binary representation of n.

Input:

The first line of the input contains an integer T, denoting number of test cases. The following T lines contains an integer N each.


Output:

Print "1" if the first and last bit is set else "0".
 

Constraints:

1<=T<=10^5

1<=N<=10^9


Example:

Input

2
9
15

Output

1
0

 

Explanation:

Input : 9
Output : 1
(9)10 = (1001)2, only the first and
last bits are set.

Input : 15
Output : 0
(15)10 = (1111)2, except first and last
there are other bits also which are set.

** 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.