Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

90% of /prog/ cannot write this BASIC PROGRAM

Name: Anonymous 2008-05-08 20:11

Task: Using your language of choice, implement a program that will a) Prompt the user for 2 numbers, and b) output the number of prime numbers between the two numbers (inclusive.)

Output: A B N

Name: Anonymous 2008-05-09 18:02

>>10
Why so verbose, dude?

primes = map head $ iterate (\(x:xs) -> filter ((0/=) . (`mod` x)) xs) [2..]

main = do [lo, hi] <- mapM readIO . words =<< getLine
      print $ length $ takeWhile (<=hi) $ dropWhile (<lo) $ primes

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List