Quotient and remainder calculator


The division with a remainder or Euclidean division of two natural numbers provides a quotient, which is the number of times the second one is contained in the first one, and a remainder, which is part of the first number that remains when in the course of computing the quotient, no further full chunk of the size of the second number can be allocated.

How ​​to calculate the quotient and remainder when dividing


The quotient and remainder are calculated when dividing two integers and getting two parts:
- quotient (how many times the divisor "fits" into the dividend),
- remainder (what is left after the division).

Calculation procedure


1. Find the largest integer that, when multiplied by the divisor, does not exceed the dividend.
- This is the quotient (q).
2. Multiply the quotient by the divisor and subtract it from the dividend.
- The difference is the remainder (r).

Formula:


a = b · q + r where 0 ≤ r < b

- a = dividend
- b = divisor
- q = quotient
- r = remainder

Example 1:

17 ÷ 3
1. How many times does 3 go into 17?
- 3 × 5 = 15 (closest, does not exceed 17) → quotient = 5
2. Remainder: 17 - 15 = 2 remainder = 2
3. Verification: 17 = 3 · 5 + 2 (correct)

Result: Quotient = 5, remainder = 2

Example 2:

20 ÷ 6
1. 6 × 3 = 18 quotient = 3
2. Remainder: 20 - 18 = 2 remainder = 2
3. Verification: 20 = 6 · 3 + 2

Result: Quotient = 3, remainder = 2

Example 3:

25 ÷ 5
1. 5 × 5 = 25 quotient = 5
2. Remainder: 25 - 25 = 0 remainder = 0
3. Verification: 25 = 5 · 5 + 0

Result: Quotient = 5, remainder = 0 (no remainder)

How ​​to write it?


- In mathematics, the remainder is often denoted by the modulo operation:
17 mod 3 = 2 (remainder after division 17 : 3)

- In programming, the % operator is used (e.g. 17 % 3 = 2).

What if the divisor is greater than the dividend?


- If b > a , then quotient = 0 and remainder = a.
Example: 5 ÷ 7 q = 0 , r = 5 .


The quotient and remainder can be easily calculated using Euclidean algorithm. Just find the largest multiple of the divisor that does not exceed the dividend, and then subtract. The remainder must always be less than the divisor and non-negative.