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

→‎J: without side effects
(→‎J: add)
(→‎J: without side effects)
Line 716:
 
=={{header|J}}==
<syntaxhighlight lang="j">0coins=. 0 $[ (|,: [ <{."1@%~}:) 1![: (#:2&2@, [{:)/\. 10 2 5 10 20 50 100 200,. , 988</syntaxhighlight>
 
1 2 5 10 20 50 100 200 coins 988</syntaxhighlight>
{{out}}
<pre>41 2 5 10 20 50 100 200
1 1 1 1 1 1 1 4</pre>
1 100
1 50
1 20
1 10
1 5
1 2
1 1</pre>
 
=={{header|JavaScript}}==
559

edits