Task

Test whether an integer is even or odd.

There is more than one way to solve this task:

 Use the even and odd predicates, if the language provides them.
 Check the least significant digit. With binary integers, i bitwise-and 1 equals 0 iff i is even, or equals 1 iff i is odd.
 Divide i by 2. The remainder equals 0 iff i is even. The remainder equals +1 or -1 iff i is odd.
 Use modular congruences:
 i ≡ 0 (mod 2) iff i is even.
 i ≡ 1 (mod 2) iff i is odd.


      IF FNisodd%(14) PRINT "14 is odd" ELSE PRINT "14 is even"
      IF FNisodd%(15) PRINT "15 is odd" ELSE PRINT "15 is even"
      IF FNisodd#(9876543210#) PRINT "9876543210 is odd" ELSE PRINT "9876543210 is even"
      IF FNisodd#(9876543211#) PRINT "9876543211 is odd" ELSE PRINT "9876543211 is even"
      END
 
      REM Works for -2^31 <= n% < 2^31
      DEF FNisodd%(n%) = (n% AND 1) <> 0
 
      REM Works for -2^53 <= n# <= 2^53
      DEF FNisodd#(n#) = n# <> 2 * INT(n# / 2)