RosettaCodeData/Task/Loops-Increment-loop-index-within-loop-body/BASIC256/loops-increment-loop-index-within-loop-body.basic
2023-07-01 13:44:08 -04:00

22 lines
346 B
Text

function isPrime(number)
if (number % 2 = 0) or (number % 3 = 0) then return false
lim = sqr(number)
for i = 5 to lim step 2
if number % i = 0 then return false
next i
return true
end function
i = 42
counter = 0
while counter < 42
if isPrime(i) then
counter += 1
print "n = "; counter, i
i += i - 1
end if
i += 1
end while
end