The MOD function returns the rest of a division. This function is very useful for
- a logical test
- the conditional formatting
- data validation
Presentation of the MOD function
If you divide 12 by 3, the result is 4.
The result is a whole number, so the rest of the division is obviously 0. And this is what the function MOD returns
Now if we divide 12 by 5, the result of the division is not an integer.
The rest of the division, or the modulo, will give this result
Odd or even?
The function MOD is the most convenient way to find if a number is odd or even. The test to write is very simple.
And you can include this test in an IF function to display the result of your test
=IF(MOD(A2,2)=0,"Is even number", "Is odd number")
Other examples of use of the MOD function
You can also used the MOD function is these cases
- Test if the maturity of a contract is reached or not (divisor = 12)
- Quantity in a package (divisor depends of the number of items)
If you want to return the opposite, the integer part of a division, in that case you have to use the QUOTIENT function.
In fact, it's exactly like doing the division inside a INT function
The GCD function returns the Greatest Common Divisor 🤨🤔🙄
This function returns the greatest value that divide 2 values. For example, if you have the value 120 and 48, the result is:
=GCD(120,48) => 24
- 24 * 2 = 48
- 24 * 5 = 120