2011-03-08 07:01:27 +00:00
|
|
|
-- Haskell version of a Prime Number Finder
|
|
|
|
-- haplo@mindstab.net
|
|
|
|
|
2013-01-31 06:13:37 +00:00
|
|
|
import System.IO
|
|
|
|
import System.Environment
|
2011-03-08 07:01:27 +00:00
|
|
|
|
|
|
|
check i c m | i > m = [(show c) ++ " "]
|
|
|
|
| rem c i > 0 = check (i+2) c m
|
|
|
|
| otherwise = []
|
|
|
|
|
|
|
|
primes c m s t | c < m && c >= t = primes c m (s+1) ((s+1)*(s+1))
|
|
|
|
| c < m = check 3 c s ++ primes (c+2) m s t
|
|
|
|
| otherwise = []
|
|
|
|
|
|
|
|
main = do
|
|
|
|
x <- getArgs
|
|
|
|
print (primes 3 (read (x!!0)::Int) 2 4)
|
|
|
|
|