1 Answers
The coin problem is a mathematical problem that asks for the largest monetary amount that cannot be obtained using only coins of specified denominations, for example, the largest amount that cannot be obtained using only coins of 3 and 5 units is 7 units. The solution to this problem for a given set of coin denominations is called the Frobenius number of the set. The Frobenius number exists as long as the set of coin denominations has no common divisor greater than 1.
There is an explicit formula for the Frobenius number when there are only two different coin denominations, x and y: the Frobenius number is then xy − x − y. If the number of coin denominations is three or more, no explicit formula is known. However, for any fixed number of coin denominations, there is an algorithm computing the Frobenius number in polynomial time. No known algorithm is polynomial time in the number of coin denominations, and the general problem, where the number of coin denominations may be as large as desired, is NP-hard.