Is there more than one way to test to see if an integer is even or odd? So far I've only been abe to devise one solution. The solution makes use of the AND bitwise operator.
PBP code ...Code:public boolean isNumOdd(int num) { if (1 & num) return true; else return false; }
Has anyone got another way of doing this? I'm incredibly keen to hear your thoughts.Code:main: if 1 & num then oddNum = true else oddNum = false end if
Best Regards,
Trent Jackson
Bookmarks