MOD function

MOD(Dividend, Divisor) MOD(Dividend; Divisor)

Dividend

Number or { Number }

The number to divide.

Divisor

Number or { Number }

The number to divide the dividend parameter by.

Returns

Number or { Number }

The remainder. This value has the same sign as the dividend parameter.

Returns the remainder after an integer division operation. MOD(5, 2)MOD(5; 2) returns 1, as 2 divides 5 into two parts (2 * 2 = 42 * 2 = 4), leaving a remainder of 1 (5 - 45 - 4).

Division without remainder

MOD can be used to check if a divisor can divide a number without leaving a remainder, in which case the result is 0. 3 divides 12 into four parts, with no remainder, meaning that MOD(12, 3)MOD(12; 3) returns 0.

Checking the remainder for zero is often used to do something every nth time. This formula returns every other item, { 1, 3, 5 }{ 1; 3; 5 }:

FILTER({ 1, 2, 3, 4, 5, 6 }, MOD(Index, 2) = 0)FILTER({ 1; 2; 3; 4; 5; 6 }; MOD(Index; 2) = 0)

Related functions

The functions ISEVEN and ISODD can be seen as more specialized versions of this function.

These formulas return the same result:

ISEVEN(2)ISEVEN(2)
MOD(2, 2) = 0MOD(2; 2) = 0

These formulas also return the same result:

ISODD(2)ISODD(2)
MOD(2, 2) = 1MOD(2; 2) = 1

Use the QUOTIENT function to access the division result of an integer division operation instead of the remainder. While MOD(5, 2)MOD(5; 2) returns 1 — the remainder after dividing 5 by 2— QUOTIENT(5, 2)QUOTIENT(5; 2) returns 2, the actual result.

Examples

MOD(5, 2)MOD(5; 2)

Returns 1, because 2 divides 5 into two parts (2 * 2 = 42 * 2 = 4), leaving a remainder of 1 (5 - 45 - 4).

MOD(6, 2)MOD(6; 2)

Returns 0, because 2 divides 6 into three parts (2 * 3 = 62 * 3 = 6), leaving a remainder of 0 (6 - 66 - 6).

MOD({ 5, 6 }, 2)MOD({ 5; 6 }; 2)

Returns the array { 1, 0 }{ 1; 0 }, because MOD(5, 2)MOD(5; 2) returns 1 and MOD(6, 2)MOD(6; 2) returns 0.

FILTER({ 1, 2, 3, 4, 5, 6 }, MOD(Index, 2) = 0)FILTER({ 1; 2; 3; 4; 5; 6 }; MOD(Index; 2) = 0)

Filters out every other array element, returning the array { 1, 3, 5 }{ 1; 3; 5 }.