Gnocl Cookbook‎ > ‎

Odd or Even?

Have you ever wanted a simple proc to let you know wether an integer is odd or even? If so, then the following code snippet should do the trick!

#---------------
# odd or even number?
#---------------
# returns 0 = even ; 1 = odd ;
#

proc odd n { expr $n%2 }

Comments