Close Menu
Vents MagazineVents Magazine

    Subscribe to Updates

    Get the latest creative news from FooBar about art, design and business.

    What's Hot

    Funny Birthday Wishes That Won’t Backfire

    What Is a Self-Hosted Learning Management System? Benefits, Drawbacks, and When It Makes Sense

    Donna Sicuranza: Complete Biography and TEAM Career

    Facebook X (Twitter) Instagram
    Facebook X (Twitter) Instagram
    Vents MagazineVents Magazine
    Subscribe
    • News
    • Tools
      • Financial
      • Health
      • Math
      • Everyday
      • Engineering
      • Text & Fonts
    • Tech
      • AI & Tools
      • Software
    • Science
    • Business
      • Entrepreneurship
    • Health
    • Lifestyle
    • Travel
    • Home & Living
    • Blog
    • About Us
    • Contact Us
    • Privacy Policy
    Vents MagazineVents Magazine
    You are at:Home»Free Online Calculators and Tools»Modulo Calculator

    Modulo Calculator

    All tools › Math Calculators › Arithmetic

    Find a mod n with the quotient, and compare the floored and truncated results for negative numbers.

    Find the remainder of a division: a mod n

    The modulo operation gives the remainder left over when one whole number is divided by another. 17 mod 5 is 2, because 5 goes into 17 three times with 2 left. This modulo calculator shows that remainder, the quotient that goes with it.

    It also handles the case that causes real confusion: negative numbers. There are two common ways to define the remainder when a sign is negative, and programming languages do not agree on which to use. The calculator shows both side by side, so you can see which one your textbook or your code is using.

    How to use the modulo calculator

    1. Type the number being divided into Dividend (a). It can be negative.
    2. Type the number you divide by into Divisor / modulus (n). It can be negative but not zero.
    3. Press the button. The large result is the floored remainder, the one used in mathematics.
    4. Compare the rows Floored remainder (math, Python) and Truncated remainder (JavaScript, C, Java). When both numbers are positive they are the same.

    The formula and the two conventions

    a = n x q + r, so r = a – n x q

    Here a is the dividend, n the divisor, q a whole-number quotient and r the remainder. Every convention satisfies this equation. They differ only in how the quotient q is rounded when a / n is not a whole number.

    • Floored: q is rounded down, toward negative infinity. The remainder then has the same sign as the divisor n. This is the usual meaning of “mod” in math, and it is what the % operator returns in Python.
    • Truncated: q is rounded toward zero, by dropping the decimal part. The remainder then has the same sign as the dividend a. This is what the % operator returns in JavaScript, C and Java.
    • Euclidean: the remainder is never negative, whatever the signs. For a positive divisor it equals the floored result.

    Worked example: -17 mod 5

    Enter -17 as the dividend and 5 as the divisor. The exact quotient is -3.4.

    ConventionQuotientRemainderQuotient and check row
    Floored (math, Python)-43-4, because 5 x (-4) + 3 = -17
    Truncated (JavaScript, C, Java)-3-2-3, because 5 x (-3) + (-2) = -17
    Euclidean-43never negative

    Rounding -3.4 down gives -4, and -17 – (5 x -4) = 3. Rounding -3.4 toward zero gives -3, and -17 – (5 x -3) = -2. Both are valid remainders; they differ by exactly 5, the divisor, and the row “Do the two conventions agree?” says so.

    Reading the other rows

    • Divides evenly? says yes when the remainder is 0, meaning a is a multiple of n.
    • Numbers with the same floored remainder lists neighbors of a that are n apart, such as -27, -22, -17, -12, -7. They are all congruent modulo 5.
    • Nearby dividends is a table of the five numbers below and above a.

    Where modulo is used

    • Clocks. Five hours after 10 o’clock is (10 + 5) mod 12 = 3 o’clock. In the same way 29 mod 12 = 5.
    • Even or odd. A number is even when it is 0 mod 2.
    • Days of the week. 100 days from now is 100 mod 7 = 2 weekdays later.
    • Wrapping around a list in code, where an index must return to the start after the last item.

    A common bug with negative numbers

    In a language that truncates, a line such as index = (i – 1) % length returns -1 when i is 0, which is not a valid position. The usual fix is ((x % n) + n) % n, which always lands between 0 and n – 1 for a positive n.

    Limits and assumptions

    • Whole numbers only, each between minus one trillion and one trillion.
    • The divisor cannot be zero.
    • Decimal operands, such as 7.5 mod 2, are not supported.

    Frequently asked questions

    What is the difference between modulo and remainder?

    For positive numbers, nothing. With a negative number, “remainder” often means the truncated result, which keeps the sign of the dividend, while “modulo” usually means the floored result, which keeps the sign of the divisor.

    What is a mod n when a is smaller than n?

    For positive numbers it is a itself. 3 mod 7 is 3, because 7 goes into 3 zero times and all of 3 is left over.

    Why is mod 0 not allowed?

    Finding a remainder requires dividing by n, and division by zero is undefined. Most programming languages report an error for it.

    What does “congruent modulo n” mean?

    Two numbers are congruent modulo n when they leave the same remainder after division by n, which is the same as saying their difference is a multiple of n. 17 and 2 are congruent modulo 5.

    Related calculators

    • Long Division Calculator – quotient and remainder with the working shown.
    • GCF Calculator – Euclid’s method for the greatest common factor is built on remainders.
    • Prime Number Checker – test whether a number has any divisor that leaves remainder 0.
    • Day of the Week Calculator – weekday arithmetic, which is counting mod 7.
    Top Posts

    Henry Golding Ethnicity: Complete Heritage Guide

    October 15, 202679 Views

    Why Petrol Prices Keep Rising in USA: Expert Guide

    May 17, 202673 Views

    5 Proven Side Hustles With Just a Phone in 2026

    May 16, 202673 Views

    ChatGPT vs Claude vs Gemini: Expert 2026 Guide

    May 30, 202655 Views
    Don't Miss
    Lifestyle November 3, 2026

    Funny Birthday Wishes That Won’t Backfire

    A good joke in a birthday message makes someone’s day. A bad one can sting…

    What Is a Self-Hosted Learning Management System? Benefits, Drawbacks, and When It Makes Sense

    Donna Sicuranza: Complete Biography and TEAM Career

    Henry Golding Ethnicity: Complete Heritage Guide

    Stay In Touch
    • Facebook
    • Twitter
    • Pinterest
    • Instagram
    • YouTube
    • Vimeo

    Subscribe to Updates

    Get the latest creative news from SmartMag about art & design.

    Demo
    Our Picks

    Funny Birthday Wishes That Won’t Backfire

    What Is a Self-Hosted Learning Management System? Benefits, Drawbacks, and When It Makes Sense

    Donna Sicuranza: Complete Biography and TEAM Career

    Most Popular

    How Do Fireflies Glow? The Complete Science Explained

    May 15, 20260 Views

    5 Best Free AI Background Remover Tools in 2026 (Tested on 30 Real Images)

    May 16, 20260 Views

    Why You Feel Tired After Eating Rice: The Real Science and What to Do

    May 16, 20260 Views
    © 2026 Vents Magazine. All Rights Reserved.
    • Home
    • About Us
    • Contact Us
    • Disclaimer
    • Privacy Policy
    • Write for Us
    • DMCA Policy
    • Terms and Conditions
    • Tools

    Type above and press Enter to search. Press Esc to cancel.