Count the coins: Difference between revisions

no edit summary
(Added Quackery.)
No edit summary
Line 1,674:
 
=={{header|Go}}==
{{trans|lisp}}
A translation of the Lisp code referenced by the task description:
<lang go>package main
 
Line 3,669:
<pre> 242
13398445413854501</pre>
 
=={{header|Vlang}}==
{{trans|go}}
<lang go>fn main() {
amount := 100
println("amount, ways to make change: $amount ${count_change(amount)}"))
}
fn count_change(amount int) i64 {
return cc(amount, 4)
}
fn cc(amount int, kinds_of_coins int) i64 {
if amount == 0 {
return 1
} else if amount < 0 || kinds_of_coins == 0 {
return 0
}
return cc(amount, kinds_of_coins-1) +
cc(amount - first_denomination(kinds_of_coins), kinds_of_coins)
}
fn first_denomination(kinds_of_coins int) int {
match kinds_of_coins {
1 {
return 1
}
2 {
return 5
}
3 {
return 10
}
4 {
return 25
}
}
}</lang>
Output:
<pre>
amount, ways to make change: 100 242
</pre>
 
=={{header|Wren}}==
338

edits