Loops/Increment loop index within loop body: Difference between revisions

→‎{{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 == 2 OR x == 3 OR x == 5 then =true
Break
}
if frac(x/2 )mod 2 else exit
if frac(x/ mod 3) else exit
x1=sqrt(x): d=5@
{if frac(x/d )mod d else exit
d += 2@: if d>x1 then =true : exit
if frac(x/ mod d) else exit
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 currencydecimal i
i=Limit
{
if n<limitLimit Else exit
if isPrime(i) then n++ : Print format$("n={0::2}: {1:-20}", n, str$(i,"#,###")) : i+=i-1
i++
404

edits