Docs

FOR, WHILE, and REPEAT loops

Choose the right pseudocode loop for fixed counts, pre-condition repetition, and validation tasks.

Updated 2026-05-04

Pick the loop by intent

Use FOR when the repeat count is known. Use WHILE when a condition must be checked before each run. Use REPEAT UNTIL when the body must run at least once.

FOR Index <- 1 TO 5
    OUTPUT Index
NEXT Index

Avoid endless loops

A WHILE loop must update the value used by the condition. If the condition never changes, the program cannot finish.