Logo

MonoCalc

/

Modulo Calculator

Math

Inputs

Results

Standard Remainder (a mod b)
5

Division Identity

29 = 6 × 4 + 5

Batch Evaluation

Dividend (a)Std RemainderEuclidean RemainderQuotient
5550
17552
29554
41556

About This Tool

🔢 Modulo Calculator – Remainders, Euclidean Mod & Modular Arithmetic

The modulo operation finds the remainder left over after dividing one number by another. It is one of the most frequently used operations in mathematics and computer science, appearing in everything from clock arithmetic and cryptography to game loops and hash functions.

How the Modulo Operation Works

Given a dividend a and a divisor b, integer division produces a quotient q and a remainder r such that:

a = b × q + r

The remainder r is what the modulo operator returns. For example, 29 mod 6 = 5 because 29 = 6 × 4 + 5.

Standard vs. Euclidean Modulo

Most programming languages use truncation-based division, which can yield a negative remainder when the dividend is negative:

-29 mod 6  →  -5   (JavaScript, C, Java)

Euclidean modulo always returns a non-negative result by using the floor function:

r = a − b × floor(a / b)
-29 mod 6  →  1   (Euclidean)

This is mathematically preferred because the remainder is always in the range [0, |b|), making it easier to reason about congruence classes.

Calculation Modes

ModeWhat it computesExample
StandardTruncation-based remainder (matches most languages)29 mod 6 = 5
EuclideanAlways non-negative remainder via floor division−29 mod 6 = 1
QuotientInteger quotient and remainder togetherq = 4, r = 5
CongruenceTests whether a ≡ b (mod n)29 ≡ 5 (mod 6) ✓
Range WrapMaps a value into a cyclic range [start, end)wrap(26, 0, 24) = 2

Congruence and Modular Arithmetic

Two integers a and b are congruent modulo n — written a ≡ b (mod n) — if their difference a − b is divisible by n. Equivalently, they share the same Euclidean remainder when divided by n. Modular arithmetic underlies RSA encryption, calendar calculations, and cyclic group theory.

Clock Arithmetic and Range Wrapping

Range wrapping uses modulo to fold a value back into a fixed interval. The general formula for wrapping into [start, end) is:

wrapped = start + ((value − start) mod (end − start))

Practical uses include 24-hour clock rollover (span = 24), weekday cycling (span = 7), RGB channel wrapping, and array-index rotation in circular buffers.

Batch Evaluation

The batch feature applies one modulus to a list of dividends simultaneously and presents the results in a sortable table. This is useful for checking divisibility patterns, constructing modular sequences, or validating checksums across many values at once.

Common Applications

  • Programming: index % arrayLength for safe circular indexing; even/odd detection with n % 2.
  • Cryptography: Modular exponentiation powers RSA, Diffie-Hellman, and elliptic-curve algorithms.
  • Calendars: Zeller's congruence and ISO weekday formulas use mod 7.
  • Checksums: ISBN-13, credit-card Luhn algorithm, and EAN barcodes all rely on modular arithmetic.
  • Hashing: Hash tables map keys to buckets with hash(key) % tableSize.

Sign Conventions Across Languages

Different languages treat negative dividends differently. JavaScript's % operator and C's % follow truncation (result has the sign of the dividend). Python's % and Haskell's mod follow floor division (result always non-negative for a positive modulus), matching the Euclidean definition. Use the Euclidean mode in this calculator for math-consistent, language-neutral results.

Frequently Asked Questions

Is the Modulo Calculator free?

Yes, Modulo Calculator is totally free :)

Can I use the Modulo Calculator offline?

Yes, you can install the webapp as PWA.

Is it safe to use Modulo Calculator?

Yes, any data related to Modulo Calculator only stored in your browser (if storage required). You can simply clear browser cache to clear all the stored data. We do not store any data on server.

What is the modulo operation?

The modulo operation finds the remainder after dividing one number by another. For example, 29 mod 6 = 5 because 29 = 6 × 4 + 5, and the leftover after dividing is 5. It is widely used in programming, cryptography, and cyclic arithmetic.

What is the difference between standard modulo and Euclidean modulo?

Standard modulo (as used in most programming languages) can return a negative result when the dividend is negative. Euclidean modulo always returns a non-negative remainder by using the floor function: r = a − b × floor(a / b). For positive inputs the two are identical; they differ only for negative dividends.

How does the congruence checker work?

Two integers a and b are congruent modulo n (written a ≡ b mod n) if their difference is divisible by n. Enter both values and a modulus to test whether they belong to the same congruence class.

What is clock arithmetic / range wrapping?

Range wrapping maps any integer into a bounded cyclic range such as hours (0–23) or weekdays (0–6). It uses the formula: wrapped = start + ((value − start) mod (end − start)). This is useful for circular buffers, game loops, and scheduling.

Can I calculate modulo for decimal numbers?

Yes. The Euclidean formula r = a − b × floor(a / b) generalises to real numbers. Enable decimal mode and set the desired precision. Note that floating-point arithmetic may introduce tiny rounding errors for very large or very precise decimals.

What does the batch evaluation feature do?

Batch evaluation lets you supply a comma-separated list of dividends and applies the same modulus to all of them at once, producing a table of results. This is handy for quickly checking divisibility patterns or generating sequences in modular arithmetic.