Loops/Increment loop index within loop body: Difference between revisions
Loops/Increment loop index within loop body (view source)
Revision as of 11:41, 22 May 2020
, 4 years ago→{{header|M2000 Interpreter}}: now is ok for indexes above 39
(→{{header|Wren}}: Now uses 'fmt' module. Changed preamble slightly.) |
(→{{header|M2000 Interpreter}}: now is ok for indexes above 39) |
||
Line 2,601:
Function IsPrime (x) {
if x<=5 OR frac(x) then {
if x
Break
}
if
if
x1=sqrt(x): d=5@
{if
d += 2@: if d>x1 then =true : exit
if
d += 4@: if d<= x1 else =true: exit
loop
}
Line 2,618:
\\ so we have to use Block iterator, using Loop which set a flag current block to repeat itself once.
def long Limit=42, n
def
i=Limit
{
if n<
if isPrime(i) then n++ : Print format$("n={0::2}: {1:-20}", n, str$(i,"#,###")) : i+=i-1
i++
|