Question DSA-BIT-0025
EasyWhich test checks whether a positive integer n is a power of two?
- A.
n % 2 == 1
- B.
n ^ n == 0
- C.
Sign up free to see the answer and a step-by-step explanation.
Popular companies
Prepare company by company
Hiring pattern, syllabus, past questions and mocks for each company.
All companiesPractice by subject
Bit Manipulation question
Which test checks whether a positive integer n is a power of two?
n % 2 == 1
n ^ n == 0
Sign up free to see the answer and a step-by-step explanation.
n >> 1 == 0
n & (n − 1) == 0