Version without JavaScript, read-only: workshops, quizzes and running code are not available here. Full version · Catalogue · Sign in
Sequence
Even or odd
Core exercise
Write estPair(int n) that returns true if n is even.
A workshop goes here: you write and run code in it. It requires JavaScript.
Starting code
Exercices.java
public class Exercices {
public static void main(String[] args) {
System.out.println("4 pair ? " + estPair(4));
System.out.println("7 pair ? " + estPair(7));
}
public static boolean estPair(int n) {
// TODO
return false;
}
}
The core exercise is validated in the workshop, which requires JavaScript.
Hint 1
The remainder of integer division by 2: the % operator. Watch out for negative numbers: -4 % 2 is indeed 0.