Coin change problem (source code)

= Coin change problem

= Coin change
{synonym}

The <coin change problem> asks how denominations can form a target amount. Common versions minimize the number of coins, count unordered combinations, or count ordered sequences; these are different problems.

For <positive integer> denominations, the minimum-count recurrence is $M(0)=0$ and $M(t)=1+\min_{c_i\leq t}M(t-c_i)$, using infinity for unreachable amounts. For denominations $1,3,4$ and target six, the optimum is $3+3$, whereas a largest-first greedy rule gives $4+1+1$.

For unordered counting with unlimited coins, process denominations outside the increasing-amount loop. Reversing those loops counts ordered sequences because each final coin becomes a separate last-step choice. Stating the counting convention is therefore essential.