Factored out the common part in isEven and isOdd.