To solve money change problems, pick the largest denomination that fits the remaining amount, subtract it, and repeat until the balance is zero; this greedy method is optimal for US coins because the system is canonical. That single rule answers most cash-register and textbook questions, but it fails for some foreign coin sets and for constraint variants like limited coin inventories. This explainer covers the mechanism, the proof that makes it work, the edge cases that break it, and how professionals adapt when the greedy answer is wrong.
The greedy mechanism, step by step
The standard algorithm works on the residual amount. Start with the target, test each denomination from largest to smallest, and take as many of the largest coin as fit without exceeding what remains. In US currency the denominations are USD 1, USD 0.50, USD 0.25, USD 0.10, USD 0.05, and USD 0.01.
Worked example: change of USD 0.83. Take three quarters (USD 0.75, leaving USD 0.08), then no dimes, then one nickel (USD 0.05, leaving USD 0.03), then three pennies. Total: eight coins. No combination of seven or fewer US coins reaches USD 0.83.
The mechanism works because US coins are built in near-multiples. Each denomination is at least twice the next smaller one in value for the quarter-dime-nickel-penny chain, and half-dollar-to-quarter is exactly 2. When every coin is worth at least twice its successor, replacing two smaller coins with one larger coin never increases the count. That property, called the "twice-or-more" condition, is why greedy is safe here.
Plain version: bigger coins do more work per coin, so grabbing the biggest that fits can never strand you.
Why greedy is provably optimal for US coins
A coin system is called canonical when the greedy algorithm always produces a minimum-coin answer. US coins are canonical; so are euros, British pounds in their common denominations, and most modern decimal currencies. Canonicality is a property of the whole denomination set, not of any single coin.
The intuition: if your greedy solution and the optimal solution match on the largest coin used, you can strip that coin from both sides and the problem shrinks. If they differ, you can swap the optimal solution's smaller coins for the greedy choice without increasing the count, because a coin worth at least twice the sum of the coins it replaces can cover them. This exchange argument is the core of why the answer is minimum.
That proof depends on a structural guarantee, not on arithmetic luck. For the US penny through quarter chain, the guarantee holds with room to spare. Between the half-dollar and quarter, the ratio is exactly 2, and that is still enough. The catch is that the proof only covers standard US denominations; add a USD 0.20 or USD 0.03 coin and the guarantee can break.
The single most surprising detail: greedy is not universally optimal. A coin set like 1, 3, 4 cents breaks it. For 6 cents, greedy takes 4 + 1 + 1 (three coins) but the optimum is 3 + 3 (two coins). The US system happens to be safe; that safety is a property of the set, not of the method.
Comparison table: greedy versus alternatives
| Method | Best for | Guarantee | Cost per query |
|---|---|---|---|
| Greedy | Canonical systems (US, EUR, GBP) | Minimum coins when canonical | O(k) coin types, effectively instant |
| Dynamic programming | Non-canonical coin sets | Always minimum coins | O(amount × k) states |
| Exhaustive search | Tiny amounts, teaching only | Always minimum | Combinatorial, slow past small targets |
| Greedy with inventory caps | Register with limited coins | Minimum coins not guaranteed | Greedy pass plus adjustment loop |
| Bilinear / meet-in-the-middle | Very large amounts | Minimum coins | Roughly O(amount^0.5) |
For a USD 0.83 change with six coin types, greedy checks six denominations. Dynamic programming would evaluate 84 sub-amounts (USD 0.00 through USD 0.83). At real cash-register scale that difference is invisible, but in software processing millions of transactions per second, the linear method wins by a wide margin.
Edge cases: inventory, non-canonical currencies, and rounding
Real registers rarely hold infinite coins. If the drawer has only two quarters and the change owed is USD 0.75, pure greedy takes those two, then reaches for dimes and pennies, producing a non-optimal or even impossible result. Registers solve this by checking whether enough coins exist before committing and by back-tracking to a smaller denomination.
Foreign coin systems break greedy more openly. Before the 2018 redesign, some coin sets with unusual steps produced cases where greedy used three coins where two sufficed. For any system you have not verified as canonical, test greedy against dynamic programming on every amount from 0 up to a few hundred times the smallest coin. That check is cheap and catches failures.
Rounding is the other trap. Cash transactions in countries without small coins round to the nearest available unit, typically USD 0.05. The rounding rule applies to the total, not to each line item, so the sum of rounded lines can differ from the rounded sum. Card systems skip this entirely, which is why card totals and cash totals occasionally disagree by USD 0.01 to USD 0.04.
Red flags to watch: A coin set where any coin is less than twice its next smaller coin, without proof of canonicality. Change requests near the quarter-dime boundary, where a 4-coin greedy answer can lose to a 3-coin alternative. Register drawers low on dimes or nickels during busy periods. Mixing physical rounding with per-line rounding in accounting. Using a coin-dispensing machine that assumes greedy is optimal. Applying US greedy logic to a foreign set without a brute-force check.
Common misconceptions about change-making
Misconception one: the fewest coins always come from the biggest coins first. True only for canonical sets. For a 1, 3, 4 system, the biggest-first rule is wrong on many ordinary amounts, as the 6-cent example shows.
Misconception two: US coins are canonical by tradition or law. Canonicality is mathematical, not legal. The Treasury chooses denominations; the twice-or-more structure happens to confer the property. Change the set and you change the guarantee.
Misconception three: fewest coins is always what customers want. A customer with a coin jar wanting to shed small coins may prefer 83 pennies over a single dollar bill, so optimality depends on the objective. Registers optimize coin count and speed; personal preferences run the other way.
Misconception four: dynamic programming is overkill at the register. It usually is, but the check against non-canonical sets is a few milliseconds of compute and eliminates a class of errors. The professional caveat is that dynamic programming is not free either; naive implementations scale poorly with large amounts and many coin types.
Misconception five: greedy requires candor about the coin count. The method does not promise a specific count; it promises a minimum. Saying "greedy gives eight coins" without proving no seven-coin solution exists is a claim, not a guarantee.
Practical actions for cashiers, programmers, and testers
Pick the right method by context. For standard US notes and coins, greedy is correct and fast. For any unfamiliar set, verify with dynamic programming before shipping.
Concrete steps: List the denominations in descending order and confirm each coin is at least twice the next smaller one, or prove canonicality separately. For routine change, subtract the largest fitting denomination, record it, and continue with the residual. With limited inventories, track counts per coin and back-track when a greedy step would leave an amount unpayable. For software, unit-test greedy against dynamic programming for every amount from 0 to 1,000 units of the smallest coin. Apply cash rounding once, on the total, and keep card totals unrounded. Log the coin count alongside the answer so a non-minimal result is visible.
Thresholds to reconcile explicitly: a register running low on quarters should switch to a smaller-denomination pass once fewer than two quarters remain and change exceeds USD 0.50. A drawer with fewer than 20 pennies should not promise exact change for USD 0.99 totals. These operational thresholds are separate from the mathematical proof and must be checked independently.
Limits of the greedy method and when to escalate
Greedy guarantees minimum coins only under specific conditions, and mostly for standard denomination sets. Non-canonical systems need dynamic programming, and inventory-constrained problems become a variant of the unbounded knapsack problem with no simple closed-form rule. Large-scale systems should cache precomputed answers for common change amounts rather than recompute them.
The method also says nothing about customer experience. A mathematically minimal answer of eight coins may be slower to count than a coin combination the customer prefers. Professionals separate the proof from the transaction: prove the minimum, then present the coins clearly.
Timeline table: the course of a single change transaction
| Stage | Time | Action | Failure mode |
|---|---|---|---|
| Request | 0 ms | Customer states total or amount tendered | Misheard amount |
| Registers total | 1–50 ms | System computes change owed | Tax or discount applied late |
| Greedy pass | Under 1 ms | Subtract largest fitting denominations | Inventory insufficient |
| Inventory check | 1–5 ms | Confirm enough coins of each type | Silent shortfall |
| Adjustment | 1–10 ms | Back-track to smaller coins | Non-optimal but payable answer |
| Hand-off | 2–5 s | Cashier counts and presents change | Counting error, not math error |
| Rounding | At total | Apply cash rounding once | Per-line rounding mismatch |
For most readers this is an educational walkthrough of a well-understood algorithm, not financial advice. Verify the rules of any specific payment system or jurisdiction with a qualified professional, since rounding, tax, and cash-handling regulations vary.