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

1,2,3,4,5,6,7,8,9,10,11,12,14,15,16,17,18,19,……

First, delete every second number, we get following reduced set.

1,3,5,7,9,11,13,15,17,19,…………

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.

**Input:**

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.

**Output:**

Print 1 if the given number is a lucky number else print 0. Print the answer for each testcase in a new line.

**Constraints:**

1<= T <=100

1<= N <=100000

**Example:**

**Input:**

2

5

19

**Output:**

0

1

Author: sujnesh

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.

hardikJain5 | 234 |

CodeBuddy | 196 |

bhatabhi554 | 172 |

Akkki111 | 169 |

clone | 166 |

KshatriyaYash | 1932 |

nikhil_sojan | 1374 |

lonecoder | 1236 |

SumitSingh27 | 1127 |

mazumderrohit8 | 1108 |

blackshadows | 5327 |

Ibrahim Nash | 5219 |

akhayrutdinov | 5111 |

mb1973 | 4587 |

Quandray | 4444 |

Login to report an issue on this page.