
30 May
2007
30 May
'07
1:01 p.m.
Counting can be done elegantly by 'filter' and 'length': I figured out the following code after posting:
solve d = length [(y,x) | x <- [2..d], y <- [1..(x-1)], gcd x y == 1] main = print (solve 1000000) However when running it, it gave an answer of -1255316543. How on earth can a length be negative?
length $ filter (>1) $ Monad.liftM2 gcd [2..1000] [2..1000] Thanks... now I'll just have to figure out what it does and why it does what it does.
-- View this message in context: http://www.nabble.com/Efficiency-question-tf3823154.html#a10873232 Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.