Severity: Warning

Message: count(): Parameter must be an array or an object that implements Countable

Filename: controllers/calculator.php

Line Number: 37

- 1-800-665-6601
- info@tutorpace.com

Modulo also called as modulus is an operation which is used to find the remainder when a number is divided by another number. If a and b are two numbers then it is written as a mod b or a % b. For example 7 mod 5, 7 when divided by 5 leaves a remainder 2 with quotient 1. So 7 mod 5 = 2.

**Example 1:** Find 625 mod 25.

2 5

25 6 2 5 Step 1: 62 / 25 = 2 with remainder 12

5 0 Step 2: Subtraction 62 – 50 = 12

1 2 5 Step 3: 125 / 25 = 5

1 2 5 Step 4: Subtraction 125 – 125 = 0

0

Here the dividend is 625, divisor is 25, quotient is 25 and remainder is 0.

Hence 625 mod 25 = 0 (remainder)

n mod 1 (where n is any positive number) is 0 and n mod 0 is undefined.

**Example 2:** Find 430 mod 4

1 0 7

4 4 3 0 Step 1: Division 4 / 4 = 1

4 Step 2: subtraction 4 – 4 = 0

3 Step 3: Writing the next number 3 and division 3 / 4 = 0

0 Step 4: Subtract 3 – 0 = 3

3 0 Step 5: writing the next number 0 and division 30 / 4 = 7

2 8 Step 6: Subtraction 30 – 28 = 2

2

Here the quotient is 107 and remainder is 2.

Hence 430 % 4 = 2