18 lines
385 B
Haskell
18 lines
385 B
Haskell
|
-- Haskell version of a Prime Number Finder
|
||
|
-- haplo@mindstab.net
|
||
|
|
||
|
import System
|
||
|
|
||
|
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)
|
||
|
|