Bitwise Operator to Check Odd, Regular Expression to Check Even

Published by Deep Xavier in

Create two functions:

  1. The first is isOdd() to check if a given number is odd using bitwise operator.
  2. The second is isEven() to check if a given input is even using regular expressions.

IMPORTANT

The use of the modulo (%) operator is not allowed.

Examples

isOdd(3) ➞ "Yes"
// Use Bitwise Operator

isOdd(58) ➞ "No"
// Use Bitwise Operator

isEven("0") ➞ "Yes"
// Use Regular Expression

isEven("-99") ➞ "No"
// Use Regular Expression

Notes

  • Input will only be integers (positive/negative/zero).
  • For the second function, input will be numbers in string.
  • For more info on regular expressions, check the Resources tab.
Watch a quick demo on how Edabit works.