what is the syntax for testing whether an integer variable is odd or even?
thanks in advance for any help!
what is the syntax for testing whether an integer variable is odd or even?
thanks in advance for any help!
You can use the mod operator to calculate the reminder of a division
on IsOdd(xnumber)
return xnumber mod 2
end IsOdd
This wil return 1 if the xnumber is odd and 0 if it is even
Why not return a boolean:
on IsOdd( n )
return ( (n mod 2) = 1 )
end
if IsOdd( myNumber ) then...