Math Fundamentals18 sections · 814 units
Open in Course

Nested Loops

(Multiplication rule)

If an outer loop runs n times and an inner loop runs m times, total work is n × m. If both are n, you get O(n²).

Three nested loops give O(n³). This scales worse than quadratic. You want to avoid this if possible.

Each layer of nesting multiplies complexity.