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

Content added Content deleted
(Find minimum number of coins that make a given value en FreeBASIC)
(Find minimum number of coins that make a given value en BASIC256)
Line 238: Line 238:
0 coins needed to disperse 0
0 coins needed to disperse 0
</pre>
</pre>


=={{header|BASIC256}}==
<lang BASIC256>amount = 988
sumCoins = 0
dim coins = {1, 2, 5, 10, 20, 50, 100, 200}

print "Make a value of "; amount; " using the coins 1, 2, 5, 10, 20, 50, 100 and 200:"

for n = coins[?]-1 to 0 step -1
tmp = floor(amount/coins[n])
if tmp >= 0 then
print tmp; " * "; coins[n]
sumCoins = sumCoins + tmp
amount = amount % coins[n]
end if
next n
end</lang>
{{out}}
<pre>
Igual que la entrada de FreeBASIC.
</pre>



=={{header|F_Sharp|F#}}==
=={{header|F_Sharp|F#}}==