C

Check if a number is even or odd in C1 min read

To study the parity of a number it is enough to check whether or not it is a multiple of the number 2.
Even numbers are the numbers that end with
{0, 2, 4, 6, 8, 10, 12, …, n * 2} = {2n; n is a natural or relative integer}.

Odd numbers are the numbers that end with
1, 3, 5, 7, 9, 11, 13, …, n * 2 + 1 = {2n + 1; n is a natural or relative integer}.
An even number is any number whose remainder of the division over 2 is equal to 0. It is also said that they are multiples of 2.

An odd number is any number whose remainder of the division out of 2 is equal to 1.




Even numbers are divided in two equal parts:
3 + 3 = 6
4 + 4 = 8
7 + 7 = 14

Odd numbers are not shared in two equal parts:
3 = 1 + 2
7 = 3 + 4
41 = 40 + 1

The square of even numbers is an example:
0² = 0
2² = 4
4² = 16
6² = 36

The odd number square is odd, for example:
1² = 1
3² = 9
5² = 25
7² = 49

Note:
Every prime number is an odd number except the number 2.

 

Leave a Comment