PHP: Even or odd

The simplest decision: is a number even or odd?

What to build

A program that says whether a number is even or odd.

Requirements

  • Read one integer (it may be negative or zero).
  • Print even or odd.

Input

One integer.

Output

One word.

Constraints

-1000000 ≤ n ≤ 1000000.

Example

Input:

4

Output:

even

Why it works

The remainder after dividing by 2 is 0 only for even numbers; for a negative odd number it is -1, which is not 0.

Examples

Example 1 · Input
4
Expected output
even
Example 2 · Input
7
Expected output
odd

Hints

Hint 1

A number is even when $n % 2 is 0.

Hint 2

Use if and else, or the ternary operator.

Solution

Show one correct solution (try it yourself first)
<?php
$n = (int) trim(fgets(STDIN));
echo $n % 2 === 0 ? "even" : "odd", "\n";

▶ Open this solution in the compiler

Lesson: Operators and conditions →