Created
July 12, 2013 10:30
-
-
Save public/5983421 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
import Data.List | |
import Math.NumberTheory.Primes.Sieve | |
import Control.Monad | |
import Debug.Trace | |
numWays without p = | |
let (poor, rich) = splitAt p without | |
with = poor ++ | |
zipWith (+) with rich | |
in with | |
counter = foldl numWays (1 : repeat 0) | |
main = do | |
let ways = counter $ takeWhile (<5000) [fromInteger p | p <- primes] | |
print $ ways !! 10 | |
print $ ways !! 5000 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment