GCSE · Computer Science · AQA · Spec 8525

Integer division and remainder

135 minutes is 2 hours 15 minutes. You just got two answers from one division without blinking. A program can't: it needs a different operator for each.

Computer Science · Algorithms

Trace table — dry run the code

135 minutes: how many hours and minutes is that? Predict each new value before you press Next.

1total ← 135
2real ← total / 60
3hours ← total DIV 60
4mins ← total MOD 60
5OUTPUT hours, " h ", mins, " min"
total
real
hours
mins
Output
Press Start to run the first line.
·

Ready when you are — step through one line at a time.

What do you think?

What's really left over?

A calculator shows 17 / 5 = 3.4. Now a program works out 17 DIV 5 and 17 MOD 5.

Which of these is closest to what you think right now? Be honest — nobody's watching.
How sure are you?

Same idea, different symbols

Which operation is it?

Which operation does each operator do? (Every example uses 22 and 4.)

Still to sort

Integer division (0)

How many whole times the second number fits into the first.

Where the line is: Integer division and remainder come from the same division, but integer division counts the whole groups while remainder counts what's left.

Remainder (0)

What's left over after the whole groups are taken away.

Real division (0)

Ordinary division that keeps the fractional part.

Where the line is: Real division gives 5.5; integer division gives just the whole 5 and drops the .5.

5 of 5 still to sort.

Pseudo-code and Python write these operations differently. Sort each operator by what it actually returns.

Your turn

Seconds into minutes and seconds

A timer has run for 200 seconds. Fill in the program lines that turn this into whole minutes and seconds left over, then pick the line that checks the answer.

  1. secs ← 200
  2. missing step
Which line is step 2?

Find the wrong line

Where does it go wrong?

Sam dry-runs six expressions and is sure they're all fine. Exactly one result is wrong. Which one?

Sam's results — which line goes wrong?

Remainders as tests

Even? Multiple of 3? Both?

A program checks each number with two tests. Tick every test the number passes (or neither). Some pass both — watch out for them.

  • A n MOD 2 = 0 (even)
  • B n MOD 3 = 0 (multiple of 3)
  1. 4
  2. 9
  3. 12
  4. 7
  5. 10
  6. 15
  7. 18
  8. 25

WHAT YOU'VE LEARNED

A quick recap of today's lesson.

One division, two whole-number answers: how many times it fits, and what's left over.

What you need to know

  • Real division (/) keeps the fraction: 17 / 5 = 3.4.
  • Integer division (DIV) keeps only the whole number of fives that fit: 17 DIV 5 = 3. It never rounds.
  • The remainder (MOD, also called modulus) is what's left over: 5 × 3 = 15, and 17 − 15 = 2, so 17 MOD 5 = 2.
  • Have a goYour mate's calculator says 29 / 8 = 3.625, so they proudly write 29 DIV 8 = 4. Rescue them: what are 29 DIV 8 and 29 MOD 8 really?

    29 DIV 8 = 3 and 29 MOD 8 = 5.

    Three eights make 24 and a fourth would need 32, so DIV is 3, not 4 — rounding 3.625 is the trap. Then 29 − 24 = 5 is left over.

  • Don't read the remainder off the decimal. The .4 in 3.4 is a fraction of a five, not a leftover count.
  • They always fit together: a = b × (a DIV b) + (a MOD b). Here, 17 = 5 × 3 + 2.
  • Have a goA program lost its starting number x. All you know is x DIV 6 = 4 and x MOD 6 = 1. Rebuild x.

    x = 25

    6 × 4 + 1 = 24 + 1 = 25. Stopping at 24 forgets the 1 left over, and 24 would have a remainder of 0.

  • Divides exactly? Then nothing is left over: 20 MOD 5 = 0.
  • First number smaller than the second? DIV gives 0 and MOD hands back the first number: 3 DIV 5 = 0, 3 MOD 5 = 3.
  • Have a goNo working allowed: what are 40 MOD 8 and 8 MOD 40?

    40 MOD 8 = 0 and 8 MOD 40 = 8.

    8 fits into 40 exactly (five times), so nothing's left; 40 fits into 8 zero times, so all 8 are left. Saying 0 for both mixes up the two special cases.

  • Many pseudo-codes write DIV and MOD; Python writes // and %. Learn the operation, not the symbol.
  • Remainder 0 makes a test: n MOD 2 = 0 means n is even; n MOD k = 0 means n is a multiple of k.
  • Splitting units takes both: 135 DIV 60 gives 2 hours, and 135 MOD 60 gives the 15 minutes left.

The big picture

Integer division (DIV, or // in Python) gives the whole number of times one number fits into another and throws any fraction away. The remainder (MOD, or % in Python) gives what's left over. Both are different from real division (/), which keeps the fraction, and together they fit a = b × (a DIV b) + (a MOD b). Programs use them to split a quantity into bigger and smaller units and to test whether one number divides another exactly.

Key points

1a DIV b = the whole number of times b fits into a; any fractional part is discarded, not rounded (17 DIV 5 = 3).
2a MOD b = the remainder: what's left after taking away b × (a DIV b) (17 MOD 5 = 17 − 15 = 2).
3Real division keeps the fraction: 17 / 5 = 3.4. Its decimal digits are not the remainder.
4a = b × (a DIV b) + (a MOD b), which makes a quick check on any answer.
5If b divides a exactly, a MOD b = 0. If a < b, then a DIV b = 0 and a MOD b = a.
6n MOD 2 = 0 means n is even; n MOD k = 0 means n is a multiple of k.
7To split a total into units: bigger units ← total DIV size; leftover ← total MOD size.
8The operation matters, not the symbol: DIV/MOD in many pseudo-codes, // and % in Python.

Worked example

Problem

A program packs 75 eggs into boxes of 6. Write the two lines that store the number of full boxes and the number of eggs left over, and give their values.

⚠ Watch out

Reading the remainder off a calculator. 14 / 4 = 3.5, so 14 MOD 4 must be 5, right? Nope. Four fours make 12, so the remainder is 14 − 12 = 2. The .5 is half a four, not 5 of anything.

🧠

Memory hook

DIV counts the full boxes. MOD counts what's still in your hands.

✓

Check yourself

Without a calculator, work out 44 DIV 7, 44 MOD 7, 5 DIV 12 and 5 MOD 12. Then check each pair with divisor × DIV answer + MOD answer.

Flashcards

(12)
What does a DIV b give?
The whole number of times b fits into a. Any fractional part is thrown away.
What does a MOD b give?
The remainder: what's left over after the whole groups of b are taken away from a.
7 / 2 compared with 7 DIV 2?
7 / 2 = 3.5 (real division keeps the fraction). 7 DIV 2 = 3 (whole number only).
Why is 19 DIV 5 equal to 3, not 4?
DIV doesn't round. Only three whole fives fit into 19; a fourth would need 20.
23 / 4 = 5.75. So is 23 MOD 4 equal to 75?
No. Five fours make 20, so the remainder is 23 − 20 = 3. Decimal digits are never the remainder.
How are a, b, a DIV b and a MOD b linked?
a = b × (a DIV b) + (a MOD b)
What is a MOD b when b divides a exactly?
0. Nothing is left over (e.g. 30 MOD 6 = 0).
If a is smaller than b, what are a DIV b and a MOD b?
a DIV b = 0 and a MOD b = a (e.g. 2 DIV 9 = 0, 2 MOD 9 = 2).
Python symbols for integer division and remainder?
// for integer division and % for remainder.
What does a single / do in pseudo-code and Python?
Real division, which keeps the fractional part (e.g. 9 / 2 = 4.5).
How can a program test whether n is even?
Check n MOD 2 = 0. If n MOD 2 = 1, n is odd.
How can a program test whether n is a multiple of k?
Check n MOD k = 0: no remainder means k divides n exactly.

Tap any card to flip it, or use Study as deck to go through them one at a time. In the full lesson these run as a spaced-repetition deck — you rate each card Hard, Good or Easy and the tricky ones keep coming back until they stick.

Learning with Lightbulb is opening soon

You can use this lesson now. Join the waitlist and we'll let you know when the full Lightbulb experience is ready.

Keep me posted

More AQA GCSE Computer Science topics

See the full AQA Computer Science curriculum →

How this lesson was checked. This AQA GCSE Computer Science (specification 8525)lesson was published through Lightbulb Learning's human-designed editorial process — the educational standards, accuracy rules and publication checks it must pass were authored and approved by Philip Halpin. It passed subject-specific assessment, automated educational checks and technical publication verification before going live (publication checks completed 28 October 2026). Published pages are monitored, human spot-checking is ongoing across the lesson library, and anything found wrong is corrected or withdrawn. How our lessons are made and checked. Spotted a mistake? Email hello@lightbulblearning.co and we'll review it.