Numbers were last digit is zero, are even.
Example: 10, 20, 30, 40, etc.
Attention: Zero!
The number Zero is neither odd nor even.
- A pair consists of two elements.
- Dividing a number by two, we count the number of pairs.
- Zero elements, resulting zero pairs.
In words we say:
for any integer ,
- the number is odd, if divided to two, the rest is one.
- the number is even, if divided to two, the whole not zero, and the rest is zero.
The number Zero is neither odd nor even.
JavaScript:
var pairs=Math.floor(number/2);
var remainder=number%2;
if (remainder){
console.log("Number is ODD");
}else if (pairs && remainder === 0){
console.log("Number is EVEN");
}else{
console.log("Number ZERO is neither ODD nor EVEN");
};