Ask AI
Skip to main content

Modulo operation

Function: Modulo operation

This action helps you find the remainder after one number is divided by another. It's useful when you need to know what's left over from a division, rather than the full result.

Input

  • Dividend: The number you want to divide. (Type: Number, Required)
  • Divisor: The number you want to divide the Dividend by. (Type: Number, Required)

Output

  • The remainder variable name: The name of the variable where the calculated remainder will be stored. This variable will hold a Number.

Execution Flow

Real-Life Examples

Here are some ways you can use the Modulo operation in your applications:

Example 1: Checking for Even or Odd Numbers

You want to determine if a user-entered number is even or odd.

  • Inputs:
    • Dividend: 17
    • Divisor: 2
    • The remainder variable name: IsOdd
  • Result: The variable IsOdd will contain the value 1. You can then use a condition to check if IsOdd is 0 (even) or 1 (odd).

Example 2: Distributing Items Evenly

You have 25 items and want to put them into boxes that hold 6 items each. You need to know how many items are left over.

  • Inputs:
    • Dividend: 25
    • Divisor: 6
    • The remainder variable name: RemainingItems
  • Result: The variable RemainingItems will contain the value 1. This tells you there is 1 item left after filling as many boxes as possible.

Example 3: Cycling Through a List of Options

You have a list of 7 colors, and you want to cycle through them using a counter that keeps increasing. You need to find the correct index for the color.

  • Inputs:
    • Dividend: CurrentCounterValue (e.g., 10)
    • Divisor: 7 (total number of colors)
    • The remainder variable name: ColorIndex
  • Result: If CurrentCounterValue is 10, the variable ColorIndex will contain the value 3. This means the 10th item in a cycle of 7 would correspond to the item at index 3 (assuming a 0-based index, you might add 1 to get the 4th color).