» Even number and odd number in excel. How to highlight even and odd numbers in different colors in Excel. Remainder function in excel to find even and odd numbers

Even number and odd number in excel. How to highlight even and odd numbers in different colors in Excel. Remainder function in excel to find even and odd numbers

Excel for Office 365 Excel for Office 365 for Mac Excel for the web Excel 2019 Excel 2016 Excel 2019 for Mac Excel 2013 Excel 2010 Excel 2007 Excel 2016 for Mac Excel for Mac 2011 Excel Starter 2010 Less

This article describes the formula syntax and usage of the function ETHOUNT in Microsoft Excel.

Description

Returns TRUE if the number is even and FALSE if the number is odd.

Syntax

EVEN(number)

The EVEN function syntax has the following arguments:

    Number Required. The value to check. If the number is not an integer, it is truncated.

Remarks

If the value of the number argument is not a number, the EVEN function returns the #VALUE! error value.

Example

Copy the sample data from the following table and paste it into cell A1 of a new Excel sheet. To display formula results, select them and press F2 followed by ENTER. Change the width of the columns, if necessary, to see all the data.

So, I'll start my story with even numbers. What are even numbers? Any integer that can be divided by two without a remainder is considered even. In addition, even numbers end with one of the given number: 0, 2, 4, 6 or 8.

For example: -24, 0, 6, 38 are all even numbers.

m = 2k - general formula writing even numbers, where k is an integer. This formula may be needed to solve many problems or equations in elementary grades.

There is one more kind of numbers in the vast realm of mathematics - these are odd numbers. Any number that cannot be divided by two without a remainder, and when divided by two, the remainder is equal to one, is called odd. Any of them ends with one of these numbers: 1, 3, 5, 7 or 9.

Example of odd numbers: 3, 1, 7 and 35.

n = 2k + 1 is a formula that can be used to write any odd numbers, where k is an integer.

Addition and subtraction of even and odd numbers

There is a pattern in adding (or subtracting) even and odd numbers. We have presented it with the help of the table below, in order to make it easier for you to understand and remember the material.

Operation

Result

Example

Even + Even

Even + Odd

odd

Odd + Odd

Even and odd numbers will behave the same way if you subtract rather than add them.

Multiplication of even and odd numbers

When multiplying, even and odd numbers behave naturally. You will know in advance whether the result will be even or odd. The table below shows all possible options for better understanding of information.

Operation

Result

Example

Even * Even

Even Odd

Odd * Odd

odd

Now let's look at fractional numbers.

Decimal number notation

Decimals are numbers with a denominator of 10, 100, 1000, and so on that are written without a denominator. The integer part is separated from the fractional part with a comma.

For example: 3.14; 5.1; 6.789 is everything

You can perform various mathematical operations with decimals, such as comparison, summation, subtraction, multiplication, and division.

If you want to compare two fractions, first equalize the number of decimal places by adding zeros to one of them, and then, discarding the comma, compare them as whole numbers. Let's look at this with an example. Let's compare 5.15 and 5.1. First, let's equalize the fractions: 5.15 and 5.10. Now we write them as integers: 515 and 510, therefore, the first number is greater than the second, so 5.15 is greater than 5.1.

If you want to sum two fractions, follow this simple rule: start at the end of the fraction and sum first (for example) hundredths, then tenths, then integers. With this rule, you can easily subtract and multiply decimals.

But you need to divide fractions as whole numbers, counting at the end where you need to put a comma. That is, first divide the whole part, and then the fractional part.

Also, decimal fractions should be rounded. To do this, select to what decimal place you want to round the fraction, and replace the corresponding number of digits with zeros. Keep in mind that if the digit following this digit was in the range from 5 to 9 inclusive, then the last digit that remains is increased by one. If the digit following this digit lay in the range from 1 to 4 inclusive, then the last remaining one does not change.

Standard Features

The first way is possible when using the standard functions of the application. To do this, you need to create two additional columns with formulas:

  • Even numbers - insert the formula "=IF(MOD(number;2)=0;number;0)", which will return the number if it is divisible by 2 without a remainder.
  • Odd numbers - insert the formula "=IF(MOD(number;2)=1;number;0)", which will return the number if it is not divisible by 2 without a remainder.

Then you need to determine the sum of the two columns using the "=SUM()" function.

The advantages of this method are that it will be understandable even to those users who do not professionally know the application.

The disadvantages of this method are that you have to add extra columns, which is not always convenient.

Custom function

The second method is more convenient than the first, because it uses a custom function written in VBA - sum_num(). The function returns the sum of the numbers as an integer. Either even or odd numbers are summed, depending on the value of its second argument.

Function syntax: sum_num(rng;odd):

  1. The rng argument takes the range of cells over which to sum.
  2. The odd argument takes the boolean value TRUE for even numbers or FALSE for odd numbers.

Important: Even and odd numbers can only be integers, so numbers that do not match the definition of an integer are ignored. Also, if the cell value is a term, then this row is not included in the calculation.

Pros: no need to add new columns; better control over data.

The disadvantages are the need to convert the file to .xlsm format for versions of Excel starting from version 2007. Also, the function will only work in the workbook in which it is present.

Using an array

The last method is the most convenient, because. does not require the creation of additional columns and programming.

His solution is similar to the first option - they use the same formulas, but this method, thanks to the use of arrays, calculates in one cell:

  • For even numbers - insert the formula "= SUM(IF(MOD(cell_range, 2) =0;cell_range;0))". After entering data into the formula bar, we simultaneously press the Ctrl + Shift + Enter keys, which tells the application that the data must be processed as an array, and it will enclose them in curly brackets;
  • For odd numbers - repeat the steps, but change the formula "= SUM(IF(MOD(cell_range, 2) =1;cell_range;0))".

The advantage of this method is that everything is calculated in one cell, without additional columns and formulas.

The only downside is that inexperienced users may not understand your entries.

The figure shows that all methods return the same result, which one is better must be chosen for a specific task.

Download file with the described options, you can follow this link.

· Even numbers are those that are divisible by 2 without a remainder (for example, 2, 4, 6, etc.). Each such number can be written as 2K by choosing a suitable integer K (for example, 4 = 2 x 2, 6 = 2 x 3, etc.).

· Odd numbers are those that, when divided by 2, give a remainder of 1 (for example, 1, 3, 5, etc.). Each such number can be written as 2K + 1 by choosing a suitable integer K (for example, 3 = 2 x 1 + 1, 5 = 2 x 2 + 1, etc.).

  • Addition and subtraction:
    • Hexact ± H ethnoe = H ethnoe
    • Hexact ± H even = H even
    • Heven ± H ethnoe = H even
    • Heven ± H even = H ethnoe
  • Multiplication:
    • Hblack × H ethnoe = H ethnoe
    • Hblack × H even = H ethnoe
    • Heven × H even = H even
  • Division:
    • Hethnoe / H even - it is impossible to unambiguously judge the parity of the result (if the result integer, it can be either even or odd)
    • Hethnoe / H even --- if result integer, then it H ethnoe
    • Heven / H parity - the result cannot be an integer, and therefore have parity attributes
    • Heven / H even --- if result integer, then it H even

The sum of any number of even numbers is even.

The sum of an odd number of odd numbers is odd.

The sum of an even number of odd numbers is even.

The difference of two numbers is the same parity as their sum.
(ex. 2+3=5 and 2-3=-1 are both odd)

Algebraic (with + or - signs) sum of integers It has the same parity as their sum.
(e.g. 2-7+(-4)-(-3)=-6 and 2+7+(-4)+(-3)=2 are both even)


The idea of ​​parity has many different applications. The simplest of them:

1. If objects of two types alternate in some closed chain, then there are an even number of them (and of each type equally).

2. If objects of two types alternate in some chain, and the beginning and end of the chain different types, then it has an even number of objects, if the beginning and end of the same type, then an odd number. (an even number of objects corresponds to odd number of transitions between them and vice versa !!! )

2". If the object alternates between two possible states, and the initial and final states different, then the periods of the object's stay in one state or another - even number, if the initial and final states are the same, then odd. (reformulation of paragraph 2)

3. Conversely: by the evenness of the length of an alternating chain, you can find out whether its beginning and end are of one or different types.

3". Conversely: by the number of periods of the object's stay in one of the two possible alternating states, one can find out whether the initial state coincides with the final one. (reformulation of paragraph 3)

4. If objects can be divided into pairs, then their number is even.

5. If for some reason it was possible to divide an odd number of objects into pairs, then one of them will be a pair to itself, and there may be more than one such object (but there are always an odd number of them).

(!) All these considerations can be inserted into the text of the solution of the problem at the Olympiad, as obvious statements.

Examples:

Task 1. On the plane there are 9 gears connected in a chain (the first with the second, the second with the third ... the 9th with the first). Can they rotate at the same time?

Solution: No, they can't. If they could rotate, then two types of gears would alternate in a closed chain: rotating clockwise and counterclockwise (it does not matter for solving the problem, in which one direction of rotation of the first gear ! ) Then there should be an even number of gears, and there are 9 of them?! h.i.d. (sign "?!" means getting a contradiction)

Task 2. Numbers from 1 to 10 are written in a row. Is it possible to place + and - signs between them to get an expression equal to zero?
Solution: No. Parity of the resulting expression always will match parity amounts 1+2+...+10=55, i.e. sum will always be odd . Is 0 an even number? h.t.d.