LoginLogin

Using MOD/Testing if number is even

Root / FAQs / [.]

🔒
BlackDrag0n23Created:
Is there a simple way for me to detect if a number is even or odd?

IF (NUM MOD 2)==0 THEN PRINT "It's even dawg" This is because MOD is basically the remainder after division. If a number is divisible by 2 without a remainder, it's even.

Even better:
IF !(NUM MOD 2) THEN
I wish that they didn't change % to MOD. I know that would conflict with the integer% type, but I hate using it anyway. You have to type % after all occurences of the variable, rather than just in the VAR/DIM.