Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (define (count-change amount)
- (define (cc amount kinds-of-coins)
- (cond ((= amount 0) 1)
- ((or (< amount 0) (= kinds-of-coins 0)) 0)
- (else (+ (cc (- amount
- (first-denomination kinds-of-coins))
- kinds-of-coins)
- (cc amount
- (- kinds-of-coins 1))))))
- (define (first-denomination kinds-of-coins)
- (cond ((= kinds-of-coins 1) 1)
- ((= kinds-of-coins 2) 5)
- ((= kinds-of-coins 3) 10)
- ((= kinds-of-coins 4) 25)
- ((= kinds-of-coins 5) 50)))
- (cc amount 5))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement