primes/primes.r

29 lines
531 B
R

REBOL [
Title: "Rebol Prime Number Finder"
Date: 02-Dec-2003
Author: haplo@mindstab.net
Version: 1.0
File: %primes.r
Home: http://www.mindstab.net/primes
]
; Command line argument getting code borrowed from
; http://www.melbpc.org.au/pcupdate/2305/2305article6.htm
cl_args: make block! system/script/args
max: either none? cl_args/1 [""] [to-integer cl_args/1]
for cnt 3 max +2 [
sq: to-integer(square-root(cnt))
isp: 1
for i 3 sq +2 [
isp: cnt // i
if isp = 0 [
break
]
]
if isp <> 0 [ print cnt ]
]