* Find whatter a number is Power of 2. n & (n-1) = 0.
Answers
Answered by
1
Answer:
Keep dividing the number by two, i.e, do n = n/2 iteratively until n becomes 1. In any iteration, if n%2 becomes non-zero and n is not 1 then n is not a power of 2. If n becomes 1 then it is a power of 2.
Similar questions