Lecture 05 — Numbers, Remainders, and Cycles

Position in the course

This is lecture 5 of 32. It belongs to the course arc described in the course outline and uses the standard interactive case method: display, attempt (5 minutes), discuss, reveal, name the technique.

Learning objectives

By the end of this lecture students can do all three under time pressure, which is what the four cases exercise.

Prerequisite knowledge

Before this lecture: Lecture 04 — First Python

Assumed fluencies:

Preparation task: Practise // and % on small numbers; sketch cs-017 on paper.

Detailed topic outline

Core (mandatory):

  1. integer division and remainder as design tools
  2. cycles, rotations, and schedules
  3. digit extraction
  4. reconstructing inputs from outputs

Extension (optional enrichment):

  1. simulation of a ring process
  2. when mathematics replaces loops

Case sequence

CaseTitleDifficulty
cs-017The Pager ScheduleBeginner
cs-018Digits and Their SumFoundational
cs-019The Broken KeypadIntermediate
cs-020The Josephus RingAdvanced

Display each case full-screen from the student page (cases cs-017–cs-020); instructor pages cs-017–cs-020 under case-studies/instructor/ hold the full solutions, reveal guides, and discussion prompts.

Timing plan (120 minutes)

MinutesSegment
0–10Framing: where this fits; recall of the previous lecture
10–30Case 1 (cs-017): 5-minute attempt, then discussion and reveal
30–50Case 2 (cs-018): same rhythm
50–70Case 3 (cs-019): same rhythm, harder case
70–75Break
75–100Case 4 (cs-020): same rhythm, hardest case
100–115Synthesis: name the techniques; misconceptions check
115–120Exit questions, homework, next-lecture preview

Timing flexes with the room: if a case ignites the class, let the discussion run and compress the synthesis; if the attempts stall, harvest partial attempts rather than extending the clock.

Worked examples

Instructor demonstration to open the lecture: Build the pager schedule (cs-017) as a table of n, n mod k, and the day name; the pattern falls out before any code.

Classroom activities

#ActivityMinutesFormat and prompt
1Human clock circle6Students count around a circle; the remainder rule for 'who is on call on day n' is discovered physically.
2Trace-table relay8cs-018 digit-sum trace: each pair does two rows of the table then passes it on.
3Cycle spotter5Six remainders sequences on the board; spot which are cycles and give the period.

Board plan

Instructor explanation notes

Reading the room. Modulo is the star, and it divides the room: some students see cycles instantly, others need the human clock. The Josephus case (cs-020) is marked Expert — it is a stretch goal, and the hand simulation at n = 5 is the accessible core.

Running the reveal. This is the first lecture where mathematics replaces a loop; name that trade-off explicitly.

Lecture focus. One sentence to repeat verbatim: Remainder is a design tool, not an operator trivia.

Common misconceptions

Each case's instructor page lists the specific wrong turn to expect; the reveal should address it by name.

Student practice exercises

Core:

  1. Tabulate n mod 7 for n = 1..21 and mark the pager rotation pattern.
  2. Extract the digits of 90210 by hand using // and %, then sum them.
  3. Simulate the Josephus ring (cs-020) for n = 6, k = 3 and record the elimination order.

Enrichment (optional):

Formative assessment

Exit questions (choose one; answer on a card in 60 seconds):

  1. Compute 17 mod 5 and 17 // 5, and say what each means for a 5-day cycle. Expected: 2 and 3: day-before-cycle position and completed cycles
  1. Why is remainder better than an if-chain for schedules? Expected: one expression handles all positions; no special cases to maintain
  1. What replaced a loop in the Josephus analysis? Expected: a table of small cases plus a conjecture (mathematics replacing simulation)

Cards are skimmed before the next lecture; three answers become the framing. Persistent wrong answers route students to the review stations of lecture 16 or to office hours.

Homework and preparation

Learning-outcome mapping

Differentiation