Find minimum number of coins that make a given value: Difference between revisions

Added Easylang
(Added Quackery.)
(Added Easylang)
 
(2 intermediate revisions by 2 users not shown)
Line 495:
 
 
 
=={{header|EasyLang}}==
<syntaxhighlight>
sum = 988
coins[] = [ 200 100 50 20 10 5 2 1 ]
#
for coin in coins[]
n = sum div coin
if n > 0
print "coins of " & coin & ": " & n
sum -= n * coin
.
.
</syntaxhighlight>
{{out}}
<pre>
coins of 200: 4
coins of 100: 1
coins of 50: 1
coins of 20: 1
coins of 10: 1
coins of 5: 1
coins of 2: 1
coins of 1: 1
</pre>
 
=={{header|F_Sharp|F#}}==
Line 1,410 ⟶ 1,435:
</pre>
 
 
=={{header|RPL}}==
{{works with|HP|48G}}
« { 200 100 50 20 10 5 2 1 } { }
→ coinset result
« 1 coinset SIZE '''FOR''' j
coinset j GET
MOD LASTARG / IP
'result' SWAP STO+
'''NEXT'''
DROP result DUP ∑LIST "coins" →TAG
» » '<span style="color:blue">COINS</span>' STO
 
988 <span style="color:blue">COINS</span>
{{out}}
<pre>
2: { 4 1 1 1 1 1 1 1 }
1: coins: 11
</pre>
 
=={{header|Rust}}==
Line 1,488 ⟶ 1,532:
{{libheader|Wren-fmt}}
As there is, apparently, an unlimited supply of coins of each denomination, it follows that any amount can be made up.
<syntaxhighlight lang="ecmascriptwren">import "./fmt" for Fmt
 
var denoms = [200, 100, 50, 20, 10, 5, 2, 1]
2,021

edits