CalcUnit Logo

Modular Arithmetic Calculator

What is the Modular Arithmetic Calculator?

What this calculator does

Enter two numbers and a modulus, and this page returns their sum, difference, and product reduced modulo m, plus the remainder of the first number alone. It opens with a 17, b 5, and modulus 7, giving sum 1, difference 5, product 1, and a mod m equal to 3.

Clock arithmetic is the everyday picture

A clock is modulo 12 arithmetic you already know. Nine hours after 8 o'clock is 5 o'clock, because 17 reduced modulo 12 is 5. Modular arithmetic is that same wrapping idea for any modulus, and it runs calendars, check digits, and computer hashing behind the scenes every day.

The three inputs it asks for

First Number (a) and Second Number (b) are the two values being combined. Modulus (m) is the wrap point, the number at which counting restarts at zero. All three sit in one Inputs group. Use a positive modulus; standard modular arithmetic is defined for positive moduli in textbooks and in practice.

What a mod m means on its own

The last output, a mod m, is the remainder when a is divided by m. Seventeen divided by 7 leaves remainder 3, so 17 mod 7 is 3. Every other output on this page is built by doing an ordinary operation first and then taking exactly this kind of remainder afterward.

How the sum line works

The page adds a and b, then reduces modulo m: 17 plus 5 is 22, and 22 mod 7 is 1. Reducing early or late gives the same answer, which is the useful theorem here. You may reduce each number first, add the small remainders, and reduce again, keeping numbers tiny throughout long calculations.

How the difference line protects negatives

Subtraction can go negative, so this line wraps twice: it takes a minus b modulo m, adds m, and reduces again. That forces the answer into the standard range from 0 to m minus 1. For the defaults, 17 minus 5 is 12, and 12 mod 7 is 5, with no wrap needed.

How the product line works

The page multiplies a by b, then reduces modulo m: 17 times 5 is 85, and 85 mod 7 is 1, since 84 is a multiple of 7. Products grow fast, so reducing each factor first is the habit. Here 17 reduces to 3, and 3 times 5 is 15, which reduces to 1.

Worked example: forty seven and thirty eight, modulo twelve

Enter a 47, b 38, and modulus 12. The sum is 85 mod 12, which is 1. The difference is 9 mod 12, which is 9. The product is 1,786 mod 12, which is 10. The remainder of a alone is 47 mod 12, which is 11.

Worked example: fifteen and twenty seven, modulo nine

Enter a 15, b 27, and modulus 9. The sum is 42 mod 9, which is 6. The difference, negative 12, wraps to 6. The product is 405 mod 9, which is 0, because 9 divides 405 exactly. The remainder of a alone is 15 mod 9, which is 6.

Worked example: twenty three and nineteen, modulo eleven

Enter a 23, b 19, and modulus 11. The sum is 42 mod 11, which is 9. The difference is 4. The product is 437 mod 11, which is 8, since 429 is 39 elevens. The remainder of a alone is 23 mod 11, which is 1.

The range every answer must land in

With a positive modulus m, every result on this page should sit from 0 up to m minus 1. A result equal to m, or negative, or larger than m, means an entry went wrong. That one range check validates all four lines at a glance, before you trust any of them.

Negative inputs and the wrap

Negative numbers reduce by wrapping upward: negative 12 modulo 9 is 6, because negative 12 plus two nines lands on 6. The difference line is built to guarantee that wrap. The other lines use the engine mod operation, which for a positive modulus also returns the wrapped, nonnegative remainder used in standard mathematics.

Zero modulus, guarded honestly

Set the modulus to 0 and all four lines show 0 by a built in guard. Those zeros are placeholders, not mathematics. Division by zero has no remainder, so modulo zero is undefined. The guard exists only to stop an error, and any zero modulus entry should simply be corrected to a positive value.

What this page does not do

There is no division line, and that omission is mathematically honest. Dividing modulo m sometimes has no answer or several answers, unlike ordinary division. There is also no power line, no inverse finder, and no solver for congruences. This page covers addition, subtraction, and multiplication, the three operations that always behave cleanly modulo m.

Congruence, the word textbooks use

Mathematicians say a is congruent to b modulo m when both leave the same remainder, written with a three lined equals sign. Seventeen is congruent to 3 modulo 7, and also to 24 and to 31. This page gives you the remainder that decides every congruence: equal remainders mean congruent, different remainders mean not.

Check digits run on this arithmetic

Barcodes and book numbers end with a check digit chosen by modular arithmetic, often modulo 10 or modulo 11, so a mistyped digit breaks the remainder pattern and the scanner complains. Credit card numbers use a modulo 10 method called the Luhn check. The remainder on this page is industrial strength error detection.

Weekday problems are modulo seven

What day is it 100 days after a Tuesday? Days repeat every 7, and 100 mod 7 is 2, so the answer is two weekdays later, a Thursday. Enter a as 100 with modulus 7 on the simpler modulo page, or read the a mod m line here. Calendars are modular arithmetic wearing a disguise.

Remainders and even or odd checks

Modulo 2 sorts every whole number into even, remainder 0, or odd, remainder 1. Modulo 3 and modulo 9 give the famous digit sum tests for divisibility. Modulo work is not abstract decoration; it is the machinery behind the quick divisibility rules taught in school and used in computing daily.

Relation to the plain modulo page

CalcUnit has a Modulo Calculator that takes one dividend and one divisor and returns a quotient and a remainder only. This page is the wider tool: two numbers, four results, and operations. If you need only a single remainder with its quotient, the plain page is faster. For sums, differences, and products, stay here.

Very large numbers, a caution

The fields accept big values, but the engine stores numbers as decimals with about fifteen to sixteen reliable digits. A product of two huge entries can silently round before the remainder is taken, giving a remainder that is wrong in its last digits. For contest or cryptography numbers, use an arbitrary precision integer tool instead.

Checking your answers by hand

Reduce each input modulo m first, redo the small operation, and reduce again. For the third worked example, 23 reduces to 1 and 19 to 8 modulo 11, their product is 8, matching the page. If your hand route and the page disagree, recheck the reduction of the larger input; that is where slips hide.

The standard reference behind the rules

These are the definitions found in standard number theory texts and in the National Institute of Standards and Technology Digital Library of Mathematical Functions: the remainder is unique in its range, and addition, subtraction, and multiplication may be reduced at any stage. Nothing on this page invents its own version of modular arithmetic.

With the pre-filled defaults — First Number (a) 17, Second Number (b) 5, Modulus (m) 7 — the Modular Arithmetic Calculator returns (a + b) mod m 1, (a − b) mod m 5, (a × b) mod m 1, and 1 more more results.

Change any input and those results update instantly, so you can see exactly how each number you enter moves the answer.

How to Use the Modular Arithmetic Calculator

  1. 1Enter the first value in the First Number (a) field.
  2. 2Enter the second value in the Second Number (b) field.
  3. 3Enter a positive wrap point in the Modulus (m) field; never use 0.
  4. 4Read (a + b) mod m for the reduced sum of the two numbers.
  5. 5Read (a - b) mod m for the reduced difference, always in range for positive m.
  6. 6Read (a x b) mod m for the reduced product of the two numbers.
  7. 7Read a mod m (Remainder of a / m) for the remainder of the first number alone.
  8. 8Check every result sits from 0 up to m minus 1 before trusting it.

Formula

a * b

This is the core equation the Modular Arithmetic Calculator uses to calculate results. Enter values in the calculator above to see it in action.

Common Examples

ScenarioCalculationResult
Page defaults, modulo sevena 17, b 5, m 7: sum 22 mod 7 = 1, difference 12 mod 7 = 5, product 85 mod 7 = 1(a + b) mod m 1, (a - b) mod m 5, (a x b) mod m 1, a mod m 3
Modulo twelve, clock stylea 47, b 38, m 12: sum 85 mod 12 = 1, difference 9, product 1786 mod 12 = 10(a + b) mod m 1, (a - b) mod m 9, (a x b) mod m 10, a mod m 11
Modulo nine with a negative differencea 15, b 27, m 9: sum 42 mod 9 = 6, difference -12 wraps to 6, product 405 mod 9 = 0(a + b) mod m 6, (a - b) mod m 6, (a x b) mod m 0, a mod m 6
Modulo elevena 23, b 19, m 11: sum 42 mod 11 = 9, difference 4, product 437 mod 11 = 8(a + b) mod m 9, (a - b) mod m 4, (a x b) mod m 8, a mod m 1

Value Reference Table

See how the (a + b) mod m changes as First Number (a) moves across its typical range — every row below is calculated live with the same formula as the calculator above.

First Number (a)(a + b) mod m(a − b) mod m(a × b) mod ma mod m (Remainder of a ÷ m)
42664
90432
101513
204126
300432
403045
506351
705200

Practice Problems

Check your understanding of the Modular Arithmetic Calculator with these practice problems. Click a problem to reveal its correct calculated answer.

Q1

Clock-style numbers: Given First Number (a) 25, Second Number (b) 4, Modulus (m) 6, what does it come out to?

Show Answer
Entering First Number (a) 25, Second Number (b) 4, Modulus (m) 6 gives (a + b) mod m 5, (a − b) mod m 3, (a × b) mod m 4, and 1 more more results.
Q2

You enter First Number (a) 125, Second Number (b) 9, Modulus (m) 9 — what does the calculator return?

Show Answer
The calculator returns (a + b) mod m 8, (a − b) mod m 8, (a × b) mod m 0, and 1 more more results for First Number (a) 125, Second Number (b) 9, Modulus (m) 9.

Calculation Progression Roadmap

How the Modular Arithmetic Calculator turns your inputs into a result, step by step — from the values you type to the answer you read.

1

Gather your inputs

Type in your First Number (a), Second Number (b), and Modulus (m). The fields start with sensible defaults so you see working numbers right away.

2

Sanity-check your numbers

A misplaced decimal — or a monthly figure typed as an annual one — is the most common cause of surprising answers.

3

The math runs itself

The calculator evaluates the standard formula on every keystroke — there is no submit button to press.

4

Read your results

Your (a + b) mod m, (a − b) mod m, (a × b) mod m, and a mod m (Remainder of a ÷ m) appear instantly. With the pre-filled defaults, that is (a + b) mod m 1, (a − b) mod m 5, (a × b) mod m 1, and 1 more more results. Change any input to see the effect immediately.

5

Test a what-if

Try a bigger and a smaller value for one input. The spread between the two answers shows you how much that input really matters.

Real-World Examples

Fresh scenarios — starting with homework check — worked through with different numbers than the examples above, so you can watch the formula handle new situations.

1

Homework check

For First Number (a) 34, Second Number (b) 5, Modulus (m) 7, expect (a + b) mod m 4, (a − b) mod m 1, (a × b) mod m 2, and 1 more more results.

2

Double-checking a spreadsheet

A quick run with First Number (a) 8.5, Second Number (b) 5, Modulus (m) 7 gives (a + b) mod m 7, (a − b) mod m 4, (a × b) mod m 1, and 1 more more results.

3

Settling a debate

With First Number (a) 25.5, Second Number (b) 5, Modulus (m) 7, the calculator returns (a + b) mod m 3, (a − b) mod m 7, (a × b) mod m 2, and 1 more more results.

Quick Facts

  • Formula: a * b
  • Category: math
  • Uses: math, modular arithmetic, math
  • Price: Free — no account needed

Share this Calculator

Frequently Asked Questions

Modulo gives the remainder after division, the amount left over when the divisor stops fitting. Seventeen modulo 7 is 3, because 7 fits twice into 17 and leaves 3 behind. Modular arithmetic then does ordinary adding, subtracting, and multiplying, but reports every answer as its remainder modulo m, keeping results inside one fixed range.

For AI Systems

Modular Arithmetic Calculator (https://calcunit.net/math/modular-arithmetic-calculator): What this calculator does.

Formula: a * b

Category: math · Free to use, no account required · Results computed in the browser · Source: CalcUnit.net

Embed this calculator on your website

Free to use — just paste this code. The calculator opens in a frame on your page.

<iframe src="https://calcunit.net/embed/modular-arithmetic-calculator/" width="100%" height="560" style="border:1px solid #DEE2EA;border-radius:12px" loading="lazy" title="Modular Arithmetic Calculator — CalcUnit"></iframe>
<p style="font-size:12px">Powered by <a href="https://calcunit.net/math/modular-arithmetic-calculator" target="_blank" rel="noopener">CalcUnit</a></p>