27 lines
538 B
Plaintext
27 lines
538 B
Plaintext
include "ConsoleWindow"
|
|
|
|
def tab 6
|
|
|
|
local fn isPrime( n as long ) as Boolean
|
|
dim as long i
|
|
dim as Boolean result
|
|
|
|
if n < 2 then result = _false : exit fn
|
|
if n = 2 then result = _true : exit fn
|
|
if n mod 2 == 0 then result = _false : exit fn
|
|
result = _true
|
|
for i = 3 to int( n^.5 ) step 2
|
|
if n mod i == 0 then result = _false : exit fn
|
|
next i
|
|
end fn = result
|
|
|
|
dim as long i, j
|
|
|
|
print "Prime numbers between 0 and 1000:"
|
|
for i = 0 to 1000
|
|
if ( fn isPrime(i) != _false )
|
|
print i, : j++
|
|
if j mod 10 == 0 then print
|
|
end if
|
|
next
|