Skip to content
Create a gist now

Instantly share code, notes, and snippets.

Embed URL


Subversion checkout URL

You can clone with
Download ZIP
Project Euler - Problem 3
import ONeillPrimes(primes)
result = iter n $ f n primes
where iter x (p:prs)
| p == x = p
| otherwise = let next = x `div` p
in iter next
$ f next (p:prs)
f n = dropWhile
(not . (== 0) . (n `mod`))
n = 600851475143

Why (\n x -> n `mod` x == 0) n when you can write just (\x -> n `mod` x == 0) ?

The predicate not . (\n x -> n `mod` x == 0) n can even be written without lambda:
not . (== 0) . (n `mod`)


Thanks for your suggestion. I wouldn't have thought of composing the two partially applied functions not . (== 0) . (n mod). I will correct the gist.
Actually, I wrote the code more than two years ago while starting to learn Haskell.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.