Anonymous user
Count the coins: Difference between revisions
m
Added recursive implementation in Clojure
(Add Nimrod) |
m (Added recursive implementation in Clojure) |
||
Line 356:
99341140660285639188927260001
992198221207406412424859964272600001</lang>
=={{header|Clojure}}==
<lang lisp>(def denomination-kind [1 5 10 25])
(defn- cc [amount denominations]
(cond (= amount 0) 1
(or (< amount 0) (empty? denominations)) 0
:else (+ (cc amount (rest denominations))
(cc (- amount (first denominations)) denominations))))
(defn count-change [amount]
"Recursive implementation."
(cc* amount denomination-kind))
(count-change 15) ; = 6 </lang>
=={{header|Coco}}==
|