Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. (define (count-change amount)
  2. (define (cc amount kinds-of-coins)
  3. (cond ((= amount 0) 1)
  4. ((or (< amount 0) (= kinds-of-coins 0)) 0)
  5. (else (+ (cc (- amount
  6. (first-denomination kinds-of-coins))
  7. kinds-of-coins)
  8. (cc amount
  9. (- kinds-of-coins 1))))))
  10. (define (first-denomination kinds-of-coins)
  11. (cond ((= kinds-of-coins 1) 1)
  12. ((= kinds-of-coins 2) 5)
  13. ((= kinds-of-coins 3) 10)
  14. ((= kinds-of-coins 4) 25)
  15. ((= kinds-of-coins 5) 50)))
  16. (cc amount 5))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement