MOD


Returns the remainder when one integer is divided by another.

Syntax:

MOD(number; divisor)

For integer arguments this function returns number modulo divisor, that is the remainder when number is divided by divisor. This function is implemented as number - divisor * INT( number/divisor) , and this formula gives the result if the arguments are not integer.

Example:

MOD(22; 3)

returns 1, the remainder when 22 is divided by 3.

MOD(11.25; 2.5)

returns 1.25.


Application:

Scheduling Work Shifts


The MOD (modulo) function is a useful tool for tasks that involve a cyclical or repeating pattern. A great example is scheduling work shifts on a rotating basis.


Imagine a small business with four employees: Alice, Bob, Charlie, and David. They work a four-day schedule, with one employee assigned to the special "closing" shift each day. The manager wants to assign the closing shift on a rotating basis, starting with Alice on Day 1.


The MOD function can be used to determine who gets the closing shift on any given day.


The formula is: MOD(Day Number, Number of Employees)

  • Day Number is the input (the current day in the cycle).
  • Number of Employees is the divisor (the size of the repeating group, which is 4 in this case).
  • The Result is the remainder, which will be a number from 0 to 3. We can then map this remainder to an employee.


Let's set up the mapping:

  • Remainder 1 = Alice
  • Remainder 2 = Bob
  • Remainder 3 = Charlie
  • Remainder 0 = David (The MOD function returns 0 when a number is perfectly divisible, so we assign this to the last person in the cycle).


Here is a table showing the schedule for the first 10 days:

Day Number

MOD(Day Number, 4)

Remainder

Employee on Closing Shift

A
B
C
D
1
1
MOD(1, 4)
1
Alice
2
2
MOD(2, 4)
2
Bob
3
3
MOD(3, 4)
3
Charlie
4
4
MOD(4, 4)
0
David
5
5
MOD(5, 4)
1
Alice
6
6
MOD(6, 4)
2
Bob
7
7
MOD(7, 4)
3
Charlie
8
8
MOD(8, 4)
0
David
9
9
MOD(9, 4)
1
Alice
10
10
MOD(10, 4)
2
Bob

As you can see, the MOD function handles the cycle. When the day number exceeds the number of employees, the remainder "resets" back to 1, restarting the rotation with Alice. This simple calculation makes it easy to predict who will be on the closing shift on any future day without manually tracking the schedule.





This page is protected by Google reCAPTCHA. Privacy - Terms.
 
Built using Zapof