Bitwise Parity
HardAcc. 48.9%
+55 XP 20
Efficiency with Bits
While the modulo operator (%) is common for checking if a number is even, professional systems often use Bitwise AND (&).
In binary, an odd number always ends with a 1. If you perform number & 1, you extract that last bit!
The Assignment
Your function receives a number num.
- Use the bitwise AND operator (
&) to check the last bit of the number. - Return
trueif the number is Even. - Return
falseif the number is Odd.
01EXAMPLE 1
Input
num = 10Output
trueExplanation: 10 in binary ends in 0, so bitwise & 1 is 0 (Even).
Constraints
- Do not use the modulo (%) operator.
- Use the bitwise & operator.
BitwiseMathProfessional
JavaScriptSystem handles I/O — write your function only
Loading...
3 Hidden
Input Arguments
num10
Expected Output
true
Click RUN to test your solution