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.
The first line of the input contains an integer T, denoting number of test cases. The following T lines contains an integer N each.
Print "1" if the first and last bit is set else "0".
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.
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.