Lucky numbers are subset of integers. Rather than going into much theory, let us see the process of arriving at lucky numbers,
Take the set of integers
First, delete every second number, we get following reduced set.
Now, delete every third number, we get
1, 3, 7, 9, 13, 15, 19,….….
Continue this process indefinitely……
Any number that does NOT get deleted due to above process is called “lucky”.
Your task is to find whether a given number n is a lucky number or not.
The first line of input contains an integer T denoting the number of test cases. Then T test cases follow. The first line of each test case contains an integer N.
Print 1 if the given number is a lucky number else print 0. Print the answer for each testcase in a new line.
1<= T <=100
1<= N <=100000
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.