Created
January 9, 2016 22:04
-
-
Save amonshiz/75969479c3f951fdd191 to your computer and use it in GitHub Desktop.
This file contains 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
permutationWithMod :: Integer -> Integer -> Integer -> Integer | |
permutationWithMod numTake setSize modValue = | |
let nums = [(setSize - numTake + 1)..setSize] | |
in foldl (\acc n -> (acc * n) `mod` modValue) 1 nums | |
main :: IO() | |
main = do | |
setSize <- getLine | |
numTake <- getLine | |
modValue <- getLine | |
print $ permutationWithMod (read numTake) (read setSize) (read modValue) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment