On this page
Imagine your wallet holds only ₹5 and ₹8 coins (the ₹8 coin is made up; the maths is not). You can pay ₹13 and ₹21, but never ₹27, and every amount above ₹27 works. One picture explains why.
What is the largest amount that cannot be paid with two coin values?
The coin problem asks for the largest amount that cannot be made from given coin values; that amount is called the Frobenius number.
For two coin values a and b with no common factor, the Frobenius number is ab − a − b, a result Wikipedia credits to James Joseph Sylvester in 1882, citing his paper in the American Journal of Mathematics. MathWorld's entry gives the same formula and calls it mathematical folklore.
The condition matters. If both coins were even, say ₹4 and ₹6, no odd amount could ever be paid, so there would be no largest impossible amount at all.
For ₹5 and ₹8: 5 × 8 − 5 − 8 = 27. Check the five amounts after it: 28 = 20 + 8, 29 = 5 + 24, 30 = 6 × 5, 31 = 15 + 16, 32 = 4 × 8. Once five amounts in a row work, adding ₹5 coins reaches every amount after them.
Why does ab − a − b work? A picture with remainders
Write the amounts 0, 1, 2, 3 and so on in five rows by their remainder when divided by 5, as in the diagram at the top. One step right adds ₹5, so once a row has one payable amount, everything to its right is payable too. Each row has a switch-on point.
The ₹5 coins never change the remainder, so a payable amount sits in the same row as the total of its ₹8 coins. A row switches on at the smallest multiple of 8 that lands in it. The multiples 0, 8, 16, 24 and 32 have remainders 0, 3, 1, 4 and 2: five different rows. They land in different rows because 5 and 8 share no factor.
The last row to switch on starts at 32, which is (a − 1) × b. The amount one step to its left, 32 − 5 = 27, is in that row and cannot be paid. Every other row switched on earlier, so every amount above 27 can be paid. In general the last switch-on point is (a − 1)b, and one step left of it is (a − 1)b − a = ab − a − b.
Why are exactly (a − 1)(b − 1)/2 amounts impossible?
Wikipedia's coin problem article says Sylvester also showed that with coprime a and b there are (a − 1)(b − 1)/2 amounts that cannot be paid.
A pairing proof shows why. Pair each amount n from 0 to 27 with 27 − n: 0 with 27, 1 with 26, and so on. In every pair, exactly one amount can be paid.
Not both. If n and 27 − n could both be paid, their sum, 27, could be paid too. It cannot.
At least one. Write n = 5x + 8y with y between 0 and 4 (the remainder picks y; x may be negative). Then 27 − n = 5(−1 − x) + 8(4 − y). If x is negative, −1 − x is zero or more, so 27 − n can be paid.
The 28 amounts from 0 to 27 make 14 pairs, so 14 are impossible. In general, 0 to ab − a − b holds (a − 1)(b − 1) amounts, and exactly half fail.
How do you use the formula in an exam problem?
Coin, stamp and pack-size questions appear in olympiad-style number theory. Use this three-step check:
Check the common factor. Find the HCF of a and b, for example with Euclid's gcd algorithm. If it is d > 1, only multiples of d can be paid, so no largest impossible amount exists.
Compute both numbers. Largest impossible amount: ab − a − b. How many are impossible: (a − 1)(b − 1)/2.
Prove it. Show that ab − a − b cannot be paid, and that the a amounts right after it can. Adding a coins to that run reaches everything larger.
Two traps. If each coin must be used at least once, set aside one a and one b first, and the largest impossible amount becomes ab. And the formula covers two coin values only: Wikipedia's coin problem article gives the three-value McNugget case of 6, 9 and 20, whose answer is 43.
If remainders or coprime numbers feel shaky, the Fermi Concept Library gives every concept in mathematics its own lesson and its place in the map. For practice, the Fermi Problem Library has worked problems with a step-by-step solver that explains the reasoning rather than printing an answer.
Try it yourself with ₹3 and ₹7 coins: the formula says 11 is the largest amount you cannot pay, with 6 impossible amounts. List them, then check that 12, 13 and 14 all work.



