Numbers were last digit is zero, are even.

Example: 10, 20, 30, 40, etc.

Attention: Zero!

The number Zero is neither odd nor even.

  1. A pair consists of two elements.
  2. Dividing a number by two, we count the number of pairs.
  3. Zero elements, resulting zero pairs.

In words we say:

for any integer , not equal zero ,
if the remainder of the division by two is zero , the number is even,
and if the remainder of the division by two is one , the number is odd.

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");
};

results matching ""

    No results matching ""