This is documentation for Mathematica 8, which was
based on an earlier version of the Wolfram Language.

# While

 Whileevaluates test, then body, repetitively, until test first fails to give True.
• While[test] does the loop with a null body.
• If Break is generated in the evaluation of body, the While loop exits.
• Continue exits the evaluation of body, and continues the loop.
• Note that in an example like the roles of and are reversed relative to C-like programming languages.
Print and increment n while the condition n<4 is satisfied:
 Print and increment n while the condition n<4 is satisfied:
 Scope   (2)
The body can be included as part of the test:
Break breaks out of the While:
Test the condition during or at the end of the loop:
 Applications   (2)
Compute the GCD of two numbers:
Count the number of iterations in a fixed-point calculation:
If the test is False, the body is never evaluated:
While returns Null:
Use Print to see the iterations:
Do iterates a fixed number of times:
NestWhile is a functional form of While:
New in 1