Integer Division and Modulo

Integer Division (div)
Integer division gives the quotient when one integer is divided by another.
Example: 17 div 5 = 3 (because 5 fits into 17 three times)
Modulo (mod)
Modulo gives the remainder after integer division.
Example: 17 mod 5 = 2
Key Relationship
The dividend can be reconstructed using quotient and remainder.
17 = (17 div 5 × 5) + (17 mod 5)
General Formula
i = (i div j × j) + (i mod j)
Terminology
- i: dividend - j: divisor - div: quotient - mod: remainder

Quiz

1. What does i div j return?



2. What does i mod j return?



3. What is 17 mod 5?



4. What is 17 div 5?



5. What does i = (i div j × j) + (i mod j) represent?