Breaking out a loop: break

### 12.3.6 Breaking out a loop: break

The break command exits a loop without finishing it.

- break takes no arguments or parentheses.
- break exits the current loop.

#### Example

Define a program:

testbreak(a,b):= {
local r;
while (true) {
if (b == 0) {break;}
r:= irem(a,b);
a:= b;
b:= r;
}
return a;
}

Then:
Input:

testbreak(4,0)

Output:

4

since the while loop is interrupted when b is 0 and a is 4.