Anonymous user
Count the coins: Difference between revisions
→{{header|Scilab}}
Line 2,491:
=={{header|Scilab}}==
{{trans|Python}}
<lang>function varargout=changes(amount, coins)
ways = zeros(1,amount + 2);
ways(1) = 1;
for coin=coins
for j=coin:(amount+1)
ways(j+1) = ways(j+1) + ways(j + 1 - coin);
end
end
varargout=list(ways(length(ways)))
endfunction
a=changes(100, [1, 5, 10, 25]);
b=changes(100000, [1, 5, 10, 25, 50, 100]);
mprintf("%.0f, %.0f", a, b);</lang>
{{out}}
<pre>242</pre>▼
▲<pre>242, 13398445413854540</pre>
=={{header|Seed7}}==
|