You are given an integer n . Check if n has an odd divisor, greater than one (does there…
- User
You are given an integer n . Check if n has an odd divisor, greater than one (does there exist such a number x (x>1 ) that n is divisible by x and x is odd).
For example, if n=6 , then there is x=3 . If n=4 , then such a number does not exist.
Input The first line contains one integer t (1≤t≤104 ) — the number of test cases. Then t test cases follow.
Each test case contains one integer n (2≤n≤1014 ).
Please note, that the input for some test cases won't fit into 32 -bit integer type, so you should use at least 64 -bit integer type in your programming language.
Output For each test case, output on a separate line:
"YES" if n has an odd divisor, greater than one; "NO" otherwise. You can output "YES" and "NO" in any case (for example, the strings yEs, yes, Yes and YES will be recognized as positive).
Example inputCopy 6 2 3 4 5 998244353 1099511627776 outputCopy NO YES NO YES YES NO i need an explanation for this problem
- Assistant
The problem asks to check if an integer n has an odd divisor greater than one.
To solve this problem, we can iterate from 2 to the square root of n and check if any number divides n evenly and is odd. If such a number exists, we output "YES". Otherwise, we output "NO".
Here is the explanation for each test case:
Test Case 1: n = 2 The only divisors of 2 are 1 and 2. Since there is no odd divisor greater than one, the output is "NO".
Test Case 2: n = 3 The only divisor of 3 is 1. Since 3 is itself an odd number, the output is "YES".
Test Case 3: n = 4 The divisors of 4 are 1, 2, and 4. Since there is no odd divisor greater than one, the output is "NO".
Test Case 4: n = 5 The only divisor of 5 is 1. Since 5 is itself an odd number, the output is "YES".
Test Case 5: n = 998244353 To check for divisors, we iterate from 2 to the square root of 998244353. We find that 17 divides 998244353 evenly, which is an odd divisor greater than one. So, the output is "YES".
Test Case 6: n = 1099511627776 The divisors of 1099511627776 are 1, 2, 4, 8, ..., 1099511627776. Since there is no odd divisor greater than one, the output is "NO".