Find minimum number of coins that make a given value: Difference between revisions
Content added Content deleted
(→{{header|AppleScript}}: Added a version in AppleScript) |
|||
Line 26: | Line 26: | ||
{} |
{} |
||
else |
else |
||
set x to item 1 of units |
set {x, xs} to {item 1 of units, rest of units} |
||
set q to n div x |
set q to n div x |
||
if 0 = q then |
if 0 = q then |
||
change( |
change(xs, n) |
||
else |
else |
||
{{q, x}} & change( |
{{q, x}} & change(xs, n mod x) |
||
end if |
end if |
||
end if |
end if |
||
Line 118: | Line 118: | ||
1 * 2 |
1 * 2 |
||
1 * 1</pre> |
1 * 1</pre> |
||
=={{header|F_Sharp|F#}}== |
=={{header|F_Sharp|F#}}== |