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.

  1. Use the bitwise AND operator (&) to check the last bit of the number.
  2. Return true if the number is Even.
  3. Return false if the number is Odd.

01EXAMPLE 1

Inputnum = 10
Outputtrue

Explanation: 10 in binary ends in 0, so bitwise & 1 is 0 (Even).

Constraints

  • Do not use the modulo (%) operator.
  • Use the bitwise & operator.
BitwiseMathProfessional
JavaScript
Loading...
3 Hidden

Input Arguments

num10

Expected Output

true

Click RUN to test your solution