Modulo Calculator — Step-by-Step Solutions
The Modulo Calculator computes remainders and performs modular arithmetic. It supports basic modulo operations, modular addition and subtraction, modular exponentiation using fast repeated squaring, and clock arithmetic with an interactive visualisation.
Enter your values to see step-by-step working. The clock arithmetic mode displays results on an SVG clock face, making modular concepts visual and intuitive.
Your calculations will appear here
How to Use the Modulo Calculator
- Choose a mode: a mod b for a remainder, Modular Add/Subtract for arithmetic inside a modulus, Modular Exponentiation for large powers, or Clock Arithmetic for time problems.
- For a mod b, enter the dividend a and the divisor b. For modular arithmetic, enter a, b and the modulus m and choose addition or subtraction. For exponentiation, enter the base, a non-negative exponent and the modulus.
- For Clock Arithmetic, pick a 12-hour or 24-hour clock, enter the start hour and the number of hours to add (a negative number goes back in time).
- The step-by-step working shows the division, the quotient and the remainder, and for exponentiation the repeated squaring that keeps numbers small.
Formula and Theory
The modulo operation gives the remainder after division. a mod b is the amount left over when a is divided by b as many whole times as possible: a = b x q + r, with 0 <= r < |b|. For example, 17 mod 5 = 2 because 17 = 3 x 5 + 2.
Two numbers are congruent modulo m if they leave the same remainder, written a = b (mod m). Congruence behaves like equality for addition, subtraction and multiplication: you can reduce at any stage. That is why (23 + 19) mod 7 can be done as (2 + 5) mod 7.
This calculator returns a non-negative remainder for a negative dividend, the usual convention in mathematics and number theory: -7 mod 5 = 3, because -7 = (-2) x 5 + 3. Many programming languages instead return -2 for -7 % 5, so results can differ from code you have seen.
Modular exponentiation uses repeated squaring, reducing after each multiplication, so even enormous powers can be computed quickly. It is the basis of public-key cryptography and of checks such as finding the last digit of a power.
Worked Examples
Example 1: Basic remainder
Problem: Calculate 17 mod 5, and then -7 mod 5.
Solution: 17 = 3 x 5 + 2, so 17 mod 5 = 2. For -7: choose the largest multiple of 5 not above -7, which is -10, so -7 = (-2) x 5 + 3 and the remainder is 3.
Answer: 17 mod 5 = 2 and -7 mod 5 = 3
Example 2: Day of the week
Problem: Today is Monday. What day is it 100 days from now?
Solution: The weekdays repeat every 7 days, so only the remainder matters. 100 = 14 x 7 + 2, so 100 mod 7 = 2. Two days after Monday is Wednesday.
Answer: Wednesday
Example 3: Modular addition and subtraction
Problem: Calculate (23 + 19) mod 7 and (4 - 9) mod 7.
Solution: 23 + 19 = 42 = 6 x 7, so the remainder is 0. For the subtraction, 4 - 9 = -5, and adding 7 gives 2, which lies in the range 0 to 6.
Answer: (23 + 19) mod 7 = 0 and (4 - 9) mod 7 = 2
Example 4: Last digit of a large power
Problem: Find the last digit of 7^222, that is 7^222 mod 10.
Solution: The last digits of powers of 7 cycle through 7, 9, 3, 1 with period 4. Since 222 = 55 x 4 + 2, 7^222 behaves like 7^2 = 49, which ends in 9. This also follows from 7^4 = 2401 = 1 (mod 10), so 7^222 = 7^2 = 49 = 9 (mod 10).
Answer: 9
Example 5: Clock arithmetic
Problem: It is 10 o'clock on a 12-hour clock. What time is it 5 hours later? On a 24-hour clock, what is 7 hours after 22:00?
Solution: 10 + 5 = 15, and 15 - 12 = 3 on a 12-hour clock. For 24 hours, 22 + 7 = 29, and 29 - 24 = 5.
Answer: 3 o'clock, and 05:00
Frequently Asked Questions
What does mod mean?
How do I calculate modulo by hand?
What is a negative number mod something?
What is the difference between modulo and division?
What happens when a is smaller than b?
Can the modulus be zero?
Related General Calculators
Percentage Calculator
Calculate percentages instantly. Find what percent of a number, percentage change, and percentage difference. Free and fast.
Fraction Calculator
Add, subtract, multiply, and divide fractions. Simplify fractions and convert to mixed numbers. Free online fraction calculator.
Ratio Calculator
Simplify ratios and find missing values in proportions. Free online ratio calculator with step-by-step results.
Exponent Calculator
Calculate powers and exponents instantly. Compute base raised to any power including negative and fractional exponents. Free online tool.
Log Calculator
Calculate logarithms with any base. Find natural log (ln), log base 10, and custom base logarithms. Free online log calculator.
Factor Calculator
Find all factors, prime factorisation, factor pairs, GCD, and LCM. Free online factor calculator with instant results.