How this instrument works
Every pair of integers a and a positive n has exactly one quotient and one remainder that satisfy a = q·n + r with 0 ≤ r < n — a fact old enough to carry Euclid's name, the division algorithm. That remainder r is what 'a mod n' means. Divisibility adds nothing new on top of it: n divides a precisely when r lands on zero, so a divisibility test is arithmetic you have already done the moment you know the remainder, not a separate calculation.
Picture the integers laid out on a line and n-sized steps marked off from zero: 0, n, 2n, 3n, and so on. The remainder is simply how far a sits past the nearest step behind it — never as much as one full step, or the next marker would have already passed it. That is the whole content of 0 ≤ r < n. Wrap that same line into a loop of length n instead of leaving it straight and you get clock arithmetic, the picture behind cryptography, calendars, and hashing alike.
The classroom shortcuts are this identity in disguise. Ten is one more than a multiple of 3 and of 9, so each digit's place value contributes the same remainder mod 3 or mod 9 as the digit itself does — which is why summing the digits of a number and checking that sum against 3 or 9 gives the same verdict as dividing the whole number outright. The last-digit check for 2, 5, and 10 works for the parallel reason: every higher place value is already a multiple of those divisors, so only the last digit can leave anything over.
- Enter the whole number you want to test into Number, a.
- Enter the divisor you're checking it against into Divisor, n — n must be positive.
- Read Remainder, a mod n for what is left over once every full multiple of n has been removed from a.
- Read Divisible? (1 = yes, 0 = no): a 1 means the remainder above was exactly zero; a 0 means it wasn't.
- Change either field to test a new pair — remainder and the divisible flag both recompute from the same division.
Worked example — does 3 divide 15?
Take a = 15 and n = 3. Removing whole multiples of 3 from 15 gives 15 = 5 × 3 + 0, so the quotient is 5 and the remainder is 0. Remainder, a mod n reads 0, and because that remainder is exactly zero, Divisible? (1 = yes, 0 = no) reads 1 — 3 divides 15 with nothing left over.
The digit-sum shortcut agrees without any division at all: 1 + 5 = 6, and 6 is a multiple of 3, so 3 divides 15. Change n to 4 with the same a = 15 and the picture flips — 15 = 3 × 4 + 3, remainder 3, so the divisible flag drops to 0, since 3 was never zero to begin with.
Questions
What does a mod n actually compute?
It computes the remainder left over after dividing a by n, following Euclid's division algorithm: the unique r satisfying a = q·n + r with 0 ≤ r < n. For 15 mod 3, q = 5 and r = 0; for 17 mod 3, q = 5 and r = 2. The remainder is always smaller than the divisor, by definition.
How is divisibility related to the remainder?
They are the same fact stated two ways. n divides a exactly when a mod n equals zero — there is no separate divisibility rule to apply once the remainder is known. This sheet's Divisible? field is literally a check of whether Remainder equals 0, nothing more.
Why does summing a number's digits test divisibility by 3 or 9?
Because 10 leaves remainder 1 when divided by either 3 or 9, every power of 10 also leaves remainder 1, so each digit contributes to the total remainder exactly as much as it contributes to the digit sum. Add the digits, check that sum against 3 or 9, and you get the same verdict a full division would give — a shortcut built entirely from this remainder identity.
Can the remainder equal or exceed the divisor?
No — by the definition used here, 0 ≤ r < n always holds, so the remainder is strictly smaller than the divisor. A result of r = n would mean one more multiple of n should have been subtracted; the division algorithm guarantees that never happens for a valid, positive n.
What happens when the divisor n is 1?
Every integer is divisible by 1, since any a divided by 1 leaves remainder 0 with no exception. Entering n = 1 here will always return remainder 0 and a divisible flag of 1, regardless of what a is — the trivial case at one end of the divisor scale.
Does this test work the same way for negative values of a?
The underlying identity a = q·n + r with 0 ≤ r < n still applies, but some programming languages compute a % n differently for negative a, returning a negative or otherwise adjusted result instead of the true 0 ≤ r < n remainder. Checking divisibility itself is unaffected either way, since a remainder of 0 stays 0 under any convention.