Lesson 2 / 3
Conditions, Loops & Invariants
Use decisions and repetition while tracking what remains true at every step.
Choose a learning mode
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.
Conditions, Loops & Invariants
Reveal one stage of the process at a time. Check the decision rule before moving from input to output.
- 1Input: n = 4
- 2Decision: is n even?
- 3Output: yes
Input: n = 4 is the active stage.
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.
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.
