User Guide

for n from 1 by 1 to 5 do
evalf(sqrt(n));
end do;
>
The by value can be negative. The loop repeats until the value of the counter
variable is strictly less than the final value.
for n from 10 by -1 to 3 do
if isprime(n) then
print(n);
end if;
end do;
>
n;>
for/in Loop
The for/in loop statement repeats a statement sequence for each component
(operand) of an expression, for example, the elements of a list.
Syntax
The for/in loop has the following syntax.
for variable in expression do
statement_sequence
end do;
>
328 8 Basic Programming