4. Check Even or Odd
EasyMath~4 min
Write a function that takes a whole number and returns the string "Even" if the number is divisible by 2, or "Odd" if it is not.
Zero counts as even. Negative numbers follow the same rule: -4 is even, -7 is odd.
Examples
Example 1
- Input:
- n = 4
- Output:
- "Even"
Example 2
- Input:
- n = 7
- Output:
- "Odd"
Example 3
- Input:
- n = -3
- Output:
- "Odd"
- Why:
- The sign does not change whether a number is even.
Constraints
-10000 <= n <= 10000n is an integer.