27 lines
315 B
Rexx
27 lines
315 B
Rexx
|
/* REXX version of a Prime Number Finder
|
||
|
haplo@mindstab.net */
|
||
|
|
||
|
max=arg(1)
|
||
|
sq=2
|
||
|
sqm=4
|
||
|
do cnt = 3 to max by +2
|
||
|
isp = 1
|
||
|
i = 3
|
||
|
do while i <= sq & isp = 1
|
||
|
if cnt // i = 0 then
|
||
|
do
|
||
|
isp = 0
|
||
|
end
|
||
|
i = i + 2
|
||
|
end
|
||
|
if isp \= 0 then
|
||
|
say cnt
|
||
|
|
||
|
if cnt >= sqm then
|
||
|
do
|
||
|
sq = sq+1
|
||
|
sqm = sq*sq
|
||
|
end
|
||
|
|
||
|
end
|