Todos los desafíos
Fácil 0 resueltos 0% de aceptación

Odd, Even, or Neither

Classify a number by whether it is an odd integer, an even integer, or neither.

Whole numbers divisible by 2 are even; other whole numbers are odd. A number with a fractional part is neither. Zero is even, and negative integers follow the same rule.

Implement number_parity(number).

Input

number: The number to classify.

Output

Return odd, even, or neither as lowercase text.

Restricciones

−1,000,000 ≤ number ≤ 1,000,000. The input is finite and has at most two decimal places.

Ejemplos

Ejemplo 1
Entrada:
number = 14

Salida esperada:
expected = "even"
Entrada:
double number = 14;

Salida esperada:
std::string expected = "even";
Entrada:
double number = 14;

Salida esperada:
string expected = "even";

Explicación

14 = 2 × 7, so it is divisible by 2.

Ejemplo 2
Entrada:
number = 3.5

Salida esperada:
expected = "neither"
Entrada:
double number = 3.5;

Salida esperada:
std::string expected = "neither";
Entrada:
double number = 3.5;

Salida esperada:
string expected = "neither";

Explicación

3.5 has a fractional part, so it is neither an odd nor an even integer.

Referencias

Este reto está adaptado para CodeUtility. Sigue el enunciado y las restricciones indicadas arriba.

Aprende de otros

Soluciones de la comunidad

Aún no hay soluciones publicadas. Resuelve este reto para compartir la primera.