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, and a program 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?
How sure are you?

Same idea, different symbols

Which operation is it?

Which operation does each operator do? (Each 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. Write the program lines that turn this into whole minutes and seconds left over, then check the answer.

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

Spot the slip

Where does it go wrong?

Sam dry-runs six expressions. 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).

  • 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

  • Predict what DIV, MOD and / return for a given pair of whole numbers.
  • Work out a remainder by taking away divisor × quotient, never by reading the decimal.
  • Handle the two special cases: exact division and a first number smaller than the second.
  • Recognise DIV/MOD in pseudo-code and // and % in Python.
  • Use DIV and MOD in a program to convert units and to test for even numbers and multiples.

The big picture

Integer division (DIV, or // in Python) gives the whole number of times one number fits into another, throwing any fraction away. The remainder (MOD, or % in Python) gives what's left over. They're different from real division (/), which keeps the fraction, and together they satisfy a = b × (a DIV b) + (a MOD b). Programs use them to split quantities into bigger and smaller units and to test whether numbers divide 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.

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, but 14 MOD 4 isn't 5: four fours make 12, so the remainder is 14 − 12 = 2.

🧠

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 30 September 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.