e1.14.scm 619 B

123456789101112131415161718192021
  1. (define (first-denomination kinds-of-coins)
  2. (cond ((= kinds-of-coins 1) 1)
  3. ((= kinds-of-coins 2) 5)
  4. ((= kinds-of-coins 3) 10)
  5. ((= kinds-of-coins 4) 25)
  6. ((= kinds-of-coins 5) 50)))
  7. (define (cc amount kinds-of-coins)
  8. (display "a")
  9. (cond ((= amount 0) 1)
  10. ((or (< amount 0) (= kinds-of-coins 0)) 0)
  11. (else (+ (cc amount (- kinds-of-coins 1))
  12. (cc (- amount
  13. (first-denomination kinds-of-coins))
  14. kinds-of-coins)))))
  15. (define (count-change amount)
  16. (cc amount 5))
  17. (count-change 100)