← Unit 2 · all exercises
Saved in this browser only

Are they all even

Return true when every whole number from 1 to n that divides n evenly is even. If n is below 1, return true — there is nothing to contradict it.

boolean allDivisorsEven(int n)

Solution.java
Loading editor…
Results

Examples

  • allDivisorsEven(4) → false1 divides 4 and 1 is odd
  • allDivisorsEven(0) → true

There are also 3 hidden tests you can't see. Solve the problem, not the examples.