**New course!**Every coder should learn

**Generative AI!**

+ 3

# Booleans

Is there a way to use a boolean to check if a number is even or odd?

3 Answers

+ 2

You can use boolean logic and some math to determine if a number is even or odd.
For example some pseudocode,
If (X % 2 == 0)
Then even
else
Odd
Modulus can be used to determine this since if a number is divisible by 2 with no remainder, it is an even number (4, 6, 120). If not then it is odd.

+ 1

write a method depending on the language from return type boolean then write a simple if your number % 2 equals 0 then return true else return false

+ 1

Use an if else statement and the % sign. I'll leave it to you to figure it out. 😃