EasyFoundational
Check Whether a Number Is Even
- Time limit
- 1 s
- Memory limit
- 128 MB
- Estimated
- 15 min
- Programming Fundamentals
Description
Given an integer n, determine whether it is even.
An integer is even if it is divisible by 2 without leaving a remainder. Otherwise, it is odd. The number 0 is even, and negative integers are also valid inputs.
Return true when n is even and false when it is odd.
Examples:
n = 8returnstrue.n = 13returnsfalse.n = -4returnstrue.
Implement isEven(n).
Constraints
-1000000000 <= n <= 1000000000
Sample cases
3Sample 1
Input
n = 8
Expected output
true
Sample 2
Input
n = 13
Expected output
false
Sample 3
Skills and languages
Concepts
- Divisibility and Remainders
- Modular Arithmetic
Languages
- Python 3
Solve this problem
Create a free account to write, run and submit your solution.
- Write Python or Java in the browser, with your draft saved as you type
- Run your code on the examples as often as you like
- Submit to a sandboxed judge and see exactly which case failed
- Ask the AI mentor for a hint without being handed the answer