Last active
August 29, 2015 14:05
-
-
Save pdswan/55786e9d8cec3366b5fe to your computer and use it in GitHub Desktop.
An illustration of the beauty of recursion and induction
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
waysToChange :: Int -> [Int] -> Int | |
waysToChange 0 _ = 1 | |
waysToChange _ [] = 0 | |
waysToChange amount denominations@(denomination:xs) | |
| amount < 0 = 0 | |
| otherwise = | |
(waysToChange (amount - denomination) denominations) + | |
(waysToChange amount xs) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment