Enter a dividend and a divisor to get a mod n, the remainder and the quotient. For negative numbers, programming languages disagree, so both answers are shown with the check q × n + r = a.
-17 mod 5
3
Floored: same sign as 5
Remainder -17 % 5
-2
Truncated: same sign as -17
Exact division
-3.4
Quotient and check
| Method | Quotient q | Result r | q × n + r = a |
|---|---|---|---|
| Floored modulo (Python %, Excel MOD) | -4 | 3 | -4 × 5 + 3 = -17 |
| Truncated remainder (C, Java, JavaScript %) | -3 | -2 | -3 × 5 + -2 = -17 |
a mod n and the remainder, side by side
Integer quotient for each method
Works for negative numbers and decimals
Check line: quotient × divisor + result = dividend
Says when a number divides exactly
See what % returns in JavaScript or Java compared with Python for negative values.
Division with remainder and modular arithmetic for number theory.
Wrap-around sums: 30 hours after 22:00 is (22 + 30) mod 24 = 4:00.
| a | n | a mod n (floored) | a % n (truncated) |
|---|---|---|---|
| 17 | 5 | 2 | 2 |
| -17 | 5 | 3 | -2 |
| 17 | -5 | -3 | 2 |
| -17 | -5 | -2 | -2 |
Related: LCM and HCF Calculator, Fraction Calculator, Roman Numeral Converter.
LCM and HCF Calculator
HCF (GCD) and LCM of 2 to 20 numbers with prime factorisation
Fraction Calculator
Add, subtract, multiply and divide fractions and mixed numbers, in lowest terms with the working
Number Base Converter
Binary, octal, decimal, hex and any base 2-36, any size, with two's complement
GST Calculator
Calculate GST amounts
TDS Calculator
Calculate TDS deductions
Discount Calculator
Calculate discounts and final price
Tip Calculator
Tip amount, total and each person's share, with round-up
Built by Edesy
Edesy builds AI products for Indian businesses. Start self-serve, no demo call needed.
AI agents that answer and make phone calls 24/7. Handle appointments, inquiries and support in Indian and global languages.
₹50 free credit. No demo call needed.