RosettaCodeData/Task/Loops-Increment-loop-index-within-loop-body/FutureBasic/loops-increment-loop-index-within-loop-body.basic

24 lines
433 B
Text
Raw Permalink Normal View History

2024-11-04 20:28:54 -08:00
BOOL local fn IsPrime( n as long )
if ( n == 2 ) then return YES
if ( n < 2 || n % 2 == 0 ) then return NO
for long i = 3 to sqr(n) step 2
if ( ( n % i ) == 0 ) then return NO
next i
end fn = YES
void local fn DoIt
long count = 0
for long i = 42 to LONG_MAX
if ( fn IsPrime( i ) )
count++
print count,i
if ( count == 42 ) then break
i += i
end if
next
end fn
fn DoIt
HandleEvents