Skip to content

Instantly share code, notes, and snippets.

@manishym
Created December 26, 2011 04:07
Show Gist options
  • Save manishym/1520506 to your computer and use it in GitHub Desktop.
Save manishym/1520506 to your computer and use it in GitHub Desktop.
Counting change recursive
(defun count-change (amount)
(labels (
(count-change-rec (amt coins)
(cond ((= amt 0) 1)
((single? coins) 1)
((< amt 0) 0)
(t (+ (count-change-rec amt (rest coins))
(count-change-rec (- amt (first coins)) coins))))))
(count-change-rec amount coins)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment