Trailing Zero Bits
EasyBit ManipulationMath
Description
Given a non-negative integer n, return the number of trailing zero bits in its binary representation. For n = 0, return 0.
Examples
Input:
n = 8Output:
3Explanation:
Binary 1000 has 3 trailing zeros.
Input:
n = 7Output:
0Explanation:
Binary 111 ends with a 1.
Input:
n = 0Output:
0Explanation:
By convention the trailing-zero count for n = 0 is defined as 0.
Constraints
- •
0 ≤ n < 2³²