Created
February 26, 2009 13:16
-
-
Save flazz/70835 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- q1 | |
sum [ n | n <- [1..1000-1], n `mod` 3 == 0 || n `mod` 5 == 0 ] | |
-- q2 | |
let fib = 1 : 1 : zipWith (+) fib (tail fib) | |
in sum (takeWhile (< 4000000) [ n | n <- fib, n `mod` 2 == 0 ]) | |
-- q3 (not working) | |
let n = 600851475143 | |
let factors n = [ (n `div` x) | x <- [2..(n `div` 2)], n `mod` (n `div` x) == 0 ] | |
let prime = null.nub.factors | |
take 1 [x | x <- (nub (factors n)), prime x ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment