APL/DEV 3.2/TP02/Parité/Parity.java

29 lines
577 B
Java
Raw Normal View History

2022-10-12 13:29:36 +02:00
public class Parity {
public static boolean even(int n) {
switch (n) {
case 0:
return true;
case 1:
return false;
default:
return even(n-2);
}
}
public static boolean odd(int n) {
switch (n) {
case 0:
return false;
case 1:
return true;
default:
return even(n-2);
}
}
public static void main(String[] args) {
System.out.println(even(64));
}
}