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.


 
set num to random of 100 -- start with a random number from 1 to 100
 
// use the 'is a' operator to test the value
if num is an odd number then put num & " is odd"
 
// see if num is divisible by 2
if num is divisible by 2 then put num & " is even (is divisible by 2)"
 
// check to see if the remainder is 0 when dividing by 2
if num rem 2 is 0 then put num & " is even (zero remainder)"
 