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

Realize in F#
m (→‎{{header|Haskell}}: Case where smallest denomination leaves an unsummed residue)
(Realize in F#)
Line 18:
<br><br>
 
=={{header|F_Sharp|F#}}==
<lang fsharp>
//Find minimum number of coins that make a given value - Nigel Galloway: August 12th., 20
let fN g=let rec fG n g=function h::t->fG((g/h,h)::n)(g%h) t |_->n in fG [] g [200;100;50;20;10;5;2;1]
fN 988|>List.iter(fun(n,g)->printfn "Take %d of %d" n g)
</lang>
{{out}}
<pre>
Take 1 of 1
Take 1 of 2
Take 1 of 5
Take 1 of 10
Take 1 of 20
Take 1 of 50
Take 1 of 100
Take 4 of 200
</pre>
=={{header|Factor}}==
{{works with|Factor|0.99 2021-06-02}}
2,171

edits