Lesson 2 / 3

Conditions, Loops & Invariants

Use decisions and repetition while tracking what remains true at every step.

Choose a learning mode

Part 1 of 6

What Conditions, Loops & Invariants means

A condition selects a path, a loop repeats while its control rule permits, and an invariant is a statement that remains true before and after every iteration.

Explore the idea

Conditions, Loops & Invariants

Reveal one stage of the process at a time. Check the decision rule before moving from input to output.

  1. 1Input: n = 4
  2. 2Decision: is n even?
  3. 3Output: yes
Input: n = 4 is the active stage.
Key relationship

This relationship is the mathematical anchor for the lesson. Read each symbol before choosing a procedure.

A loop invariant is a statement that is true before and after every completed repetition.
Learning focus

Use decisions and repetition while tracking what remains true at every step.

Reveal one stage of the process at a time. Check the decision rule before moving from input to output.

Q&A

Sign in to ask