LESSON 9: MODULUS

Lesson Outcomes

By the end of this lesson, learners will be able to:

  • Understand what modulus means
  • Apply modulus operations in calculations
  • Explain the modulus rule
  • Use modulus in programming and problem solving

Lesson Overview

In mathematics and programming, the modulus operation is used to find the remainder after division.

While integer division gives you the whole number part, modulus gives you what is left over.

This concept is widely used in:

  • Programming logic
  • Loop control
  • Data grouping
  • Conditional statements
  • Automation workflows

What is Modulus?

Modulus is the operation that returns the remainder of a division.

Example

10 ÷ 3 = 3 remainder 1

So:
10 mod 3 = 1

Modulus Rule

The modulus rule states that:

When one number is divided by another, the modulus gives the remainder left after division.

More Examples

15 mod 4 = 3
Because: 15 ÷ 4 = 3 remainder 3

20 mod 5 = 0
Because: 20 ÷ 5 = 4 remainder 0

7 mod 2 = 1
Because: 7 ÷ 2 = 3 remainder 1

Relationship Between Division and Modulus

  • Division → gives the quotient (whole number)

  • Modulus → gives the remainder

Example

17 ÷ 5

Quotient = 3
Remainder = 2

So:
17 mod 5 = 2

Modulus in Programming

In programming, modulus is represented using the symbol:

%

Example

7 % 2 = 1

Common Uses of Modulus

Modulus is extremely useful in programming and automation:

1. Checking Even or Odd Numbers

If a number mod 2 = 0 → Even
If a number mod 2 ≠ 0 → Odd

Example:
8 % 2 = 0 → Even
7 % 2 = 1 → Odd

2. Looping and Cycles

Used to repeat actions in cycles

Example:
Every 3rd step → use mod 3

3. Data Grouping

Used to divide data into groups

Example:
Sorting items into batches

4. Time Calculations

Used for time formats

Example:
Hours, minutes, seconds

Why Modulus is Important in RPA

In automation systems:

  • Helps control logic flow
  • Used in decision-making
  • Helps create efficient loops
  • Supports condition-based execution

Example in Automation

A bot processes tasks in batches of 5:

If task number % 5 = 0 → trigger action

Lesson Summary

In this lesson, learners explored:

  • The concept of modulus
  • How to calculate remainders
  • The modulus rule
  • Applications in programming and automation

Modulus is a powerful tool for controlling logic and managing data in automation systems.