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 and , using infinity for unreachable amounts. For denominations and target six, the optimum is , whereas a largest-first greedy rule gives .
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.
For an integer and , unlimited denominations admit optimal greedy algorithm. In a minimum-count solution, no smaller denomination can occur times: carrying those stamps to the next denomination reduces their count by . Thus all counts below the maximum are base- digits, whose total value is at most . The maximum-denomination count is forced to be the quotient on division by , and repeating the argument forces every greedy remainder step.
For positive integer denominations, the coin change problem asks for coins summing to a target amount ; this recurrence minimizes their number. With unlimited supply, use the recurrence in the title, , and for an unreachable amount. Classifying a solution by its last coin proves the recurrence by induction. Recording that coin reconstructs an optimum. The table uses running time and space complexity; this is a pseudopolynomial time bound.
If each available coin can be used only once, update for amounts in descending order for each coin. Descending order retains the previous row's value at and prevents reuse. Ascending order instead permits repeated use of the current coin. The distinction is a dependency invariant, not a cosmetic loop-order choice.
For denominations and with , greedy minimizes coin count. Among optimal representations choose a lexicographically maximal descending denomination-count vector. Two unit coins can be replaced by one two; two below the largest can be replaced by without increasing count but improving that vector. Thus all smaller denominations occur at most once. For the coins below , write their value as , where is their count and is the sum of their distinct power-of-two parts. If , one and units use coins, contradicting optimality. Therefore the residual below each denomination is smaller than it, forcing precisely the greedy quotients.

Articles by others on the same topic (0)

There are currently no matching articles.