For
For(start, test, incr, body)evaluates
start, and then iterativelybodyandincras long as test evaluates toTrue.
For(start, test, incr)evaluates only
incrand nobody.
For(start, test)runs the loop without any body.
See:
Examples
Compute the factorial of 10 using For:
>> n := 1>> For(i=1, i<=10, i=i+1, n = n * i)>> n3628800
>> n == 10!True
>> n := 1>> For(i=1, i<=10, i=i+1, If(i > 5, Return(i)); n = n * i)6
>> n120Related terms
Implementation status
- ✅ - full supported