# 0.22 REPEAT-UNTIL constructs

The counterpart of WHILE-DO constructs is the REPEAT-UNTIL construct. This executes the body, then checks a condition at 'UNTIL'. If the expression evaluates to FALSE, it branches back to the top of the body (marked by 'BEGIN') again. It executes at least once. This program calculates the largest common divisor.

    : lcd
         begin
               swap over mod                  \ body
               dup 0=                         \ condition
         until drop . ;

If you enter "27 21 lcd" the programs will answer "3".