You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

18 lines
414 B

-- Haskell version of a Prime Number Finder
-- haplo@mindstab.net
import System.IO
import System.Environment
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)