# Coin problem

With only 2 pence and 5 pence coins, one cannot make 3 pence, but one can make any higher integer amount.

The coin problem (also referred to as the Frobenius coin problem or Frobenius problem, after the mathematician Ferdinand Frobenius) 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 (in the logarithms of the coin denominations forming an input). 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.

## Statement

In mathematical terms the problem can be stated:

Given positive integers $a_{1},a_{2},\dots ,a_{n}$ such that gcd$(a_{1},a_{2},\dots ,a_{n})=1$ , find the largest integer that cannot be expressed as an integer conical combination of these numbers, i.e., as a sum: $k_{1}a_{1}+k_{2}a_{2}+\dots +k_{n}a_{n}$ where $k_{1},k_{2},\dots ,k_{n}$ are non-negative integers.

This largest integer is called the Frobenius number of the set $\{a_{1},a_{2},\dots ,a_{n}\}$ , and is usually denoted by $g(a_{1},a_{2},\dots ,a_{n})$ The requirement that the greatest common divisor (GCD) equal 1 is necessary in order for the Frobenius number to exist. If the GCD were not 1, then starting at some number m the only sums possible are multiples of the GCD; every number past m that is not divisible by the GCD cannot be represented by any linear combination of numbers from the set. For example, if you had two types of coins valued at 6 cents and 14 cents, the GCD would equal 2, and there would be no way to combine any number of such coins to produce a sum which was an odd number; additionally, even numbers 2, 4, 8, 10, 16 and 22 (less than m=24) could not be formed, either. On the other hand, whenever the GCD equals 1, the set of integers that cannot be expressed as a conical combination of $\{a_{1},a_{2},\dots ,a_{n}\}$ is bounded according to Schur's theorem, and therefore the Frobenius number exists.

## Frobenius numbers for small n

A closed-form solution exists for the coin problem only where n = 1 or 2. No closed-form solution is known for n > 2.

### n = 1

If n = 1, then a1 = 1 so that all natural numbers can be formed.

### n = 2

If n = 2, the Frobenius number can be found from the formula $g(a_{1},a_{2})=a_{1}a_{2}-a_{1}-a_{2}$ . This formula was discovered by James Joseph Sylvester in 1882, although the original source is sometimes incorrectly cited as, in which the author put his theorem as a recreational problem (and did not explicitly state the formula for the Frobenius number). Sylvester also demonstrated for this case that there are a total of $N(a_{1},a_{2})=(a_{1}-1)(a_{2}-1)/2$ non-representable (positive) integers.

Another form of the equation for $g(a_{1},a_{2})$ is given by Skupień in this proposition: If $a_{1},a_{2}\in \mathbb {N}$ and $\gcd(a_{1},a_{2})=1$ then, for each $n\geq (a_{1}-1)(a_{2}-1)$ , there is exactly one pair of nonnegative integers $\rho$ and $\sigma$ such that $\sigma and $n=\rho a_{1}+\sigma a_{2}$ .

The formula is proved as follows. Suppose we wish to construct the number $m\geq (a_{1}-1)(a_{2}-1)$ . Since $\gcd(a_{1},a_{2})=1$ , all of the integers $m-ja_{2}$ for $j=0,1,\ldots ,a_{1}-1$ are mutually distinct modulo $a_{1}$ . Hence there is a unique value of $j$ , say $j=\sigma$ , and a nonnegative integer $\rho$ , such that $m=\rho a_{1}+\sigma a_{2}$ : Indeed, $\rho \geq 0$ because $\rho a_{1}=m-\sigma a_{2}\geq (a_{1}-1)(a_{2}-1)-(a_{1}-1)a_{2}=-a_{1}+1$ .

### n = 3

Formulae and fast algorithms are known for three numbers though the calculations can be very tedious if done by hand.

Simpler lower and upper bounds for Frobenius numbers for n = 3 have been also determined. The asymptotic lower bound due to Davison

$f(a_{1},a_{2},a_{3})\equiv g(a_{1},a_{2},a_{3})+a_{1}+a_{2}+a_{3}\geq {\sqrt {3a_{1}a_{2}a_{3}}}$ is relatively sharp. ($f$ here is the modified Frobenius number which is the greatest integer not representable by positive integer linear combinations of $a_{1},a_{2},a_{3}$ .) Comparison with the actual limit (defined by the parametric relationship, $f(z(i))=9i^{2}+54i+79$ where $z(i)=a_{1}a_{2}a_{3}=(3i+7)(3i+10)(3i^{2}+19i+29)$ ) shows that the approximation is only 1 less than the true value as $i\rightarrow \infty$ . It is conjectured that a similar parametric upper bound (for values of $a_{1},a_{2},a_{3}$ that are pairwise-coprime and no element is representable by the others) is $f(z(i))=6i^{2}+19i+13$ where $z(i)=a_{1}a_{2}a_{3}=(3i+2)(3i+3)(6i+7)$ .

The asymptotic average behaviour of $f$ for three variables is also known:

$f(a_{1},a_{2},a_{3})\sim {\frac {8}{\pi }}{\sqrt {a_{1}a_{2}a_{3}}},$ ## Wilf's conjecture

In 1978, Wilf conjectured that given coprime integers $a_{1} , and their Frobenius number $F$ , we have

$d\geq {\frac {F+1}{F+1-g}},$ where $g$ denotes the number of all non-representable positive integers. In 2015, an asymptotic version of this was proven by Moscariello and Sammartano.

## Frobenius numbers for special sets

### Arithmetic sequences

A simple formula exists for the Frobenius number of a set of integers in an arithmetic sequence. Given integers a, d, w with gcd(ad) = 1:

$g(a,a+d,a+2d,\dots ,a+wd)=\left(\left\lfloor {\frac {a-2}{w}}\right\rfloor \right)a+d(a-1)$ The $n=2$ case above may be expressed as a special case of this formula.

In the event that $a>w^{2}-3w+1$ , we can omit any subset of the elements $a+2d,a+3d,...,a+(w-3)d,a+(w-2)d$ from our arithmetic sequence and the formula for the Frobenius number remains the same.

### Geometric sequences

There also exists a closed form solution for the Frobenius number of a set in a geometric sequence. Given integers m, n, k with gcd(mn) = 1:

$g(m^{k},m^{k-1}n,m^{k-2}n^{2},\dots ,n^{k})=n^{k-1}(mn-m-n)+{\frac {m^{2}(n-1)(m^{k-1}-n^{k-1})}{m-n}}.$ A simpler formula that also displays symmetry between the variables is as follows. Given positive integers $a,b,k$ , with $\gcd(a,b)=1,$ let $A_{k}(a,b)=\{a^{k},a^{k-1}b,\ldots ,b^{k}\}$ . Then 
$g(A_{k}(a,b))={\sigma }_{k+1}(a,b)-{\sigma }_{k}(a,b)-(a^{k+1}+b^{k+1}),$ where ${\sigma }_{k}(a,b)$ denotes the sum of all integers in $A_{k}(a,b).$ ## Examples

### McNugget numbers

One special case of the coin problem is sometimes also referred to as the McNugget numbers. The McNuggets version of the coin problem was introduced by Henri Picciotto, who included it in his algebra textbook co-authored with Anita Wah. Picciotto thought of the application in the 1980s while dining with his son at McDonald's, working the problem out on a napkin. A McNugget number is the total number of McDonald's Chicken McNuggets in any number of boxes. In the United Kingdom, the original boxes (prior to the introduction of the Happy Meal-sized nugget boxes) were of 6, 9, and 20 nuggets.

According to Schur's theorem, since 6, 9, and 20 are (setwise) relatively prime, any sufficiently large integer can be expressed as a (non-negative, integer) linear combination of these three. Therefore, there exists a largest non-McNugget number, and all integers larger than it are McNugget numbers. Namely, every positive integer is a McNugget number, with the finite number of exceptions:

1, 2, 3, 4, 5, 7, 8, 10, 11, 13, 14, 16, 17, 19, 22, 23, 25, 28, 31, 34, 37, and 43 (sequence A065003 in the OEIS).
Total 0 1 2 3 4 5
+0 0:0,0,0 1: — 2: — 3: — 4: — 5: —
+6 6:1,0,0 7: — 8: — 9:0,1,0 10: — 11: —
+12 12:2,0,0 13: — 14: — 15:1,1,0 16: — 17: —
+18 18:3,0,0 19: — 20:0,0,1 21:2,1,0 22: — 23: —
+24 24:4,0,0 25: — 26:1,0,1 27:3,1,0 28: — 29:0,1,1
+30 30:5,0,0 31: — 32:2,0,1 33:4,1,0 34: — 35:1,1,1
+36 36:6,0,0 37: — 38:3,0,1 39:5,1,0 40:0,0,2 41:2,1,1
+42 42:7,0,0 43: — 44:4,0,1 45:6,1,0 46:1,0,2 47:3,1,1
+48 48:8,0,0 49:0,1,2 50:5,0,1 51:7,1,0 52:2,0,2 53:4,1,1
+54 54:9,0,0 55:1,1,2 56:6,0,1 57:8,1,0 58:3,0,2 59:5,1,1
A possible set of combinations of boxes for a total of 0 to 59 nuggets.
Each triplet denotes the number of boxes of 6, 9 and 20, respectively.

Thus the largest non-McNugget number is 43. The fact that any integer larger than 43 is a McNugget number can be seen by considering the following integer partitions

$44=6+9+9+20$ $45=9+9+9+9+9$ $46=6+20+20$ $47=9+9+9+20$ $48=6+6+9+9+9+9$ $49=9+20+20$ Any larger integer can be obtained by adding some number of 6s to the appropriate partition above.

Alternatively, since ${\textrm {lcm}}(9,20)=180$ and $6|180$ , the solution can also be obtained by applying a formula presented for $n=3$ earlier:[dubious ]

$g(6,9,20)={\textrm {lcm}}(6,9)+{\textrm {lcm}}(6,20)-6-9-20=18+60-35=43$ Furthermore, a straightforward check demonstrates that 43 McNuggets can indeed not be purchased, as:

1. boxes of 6 and 9 alone cannot form 43 as these can only create multiples of 3 (with the exception of 3 itself);
2. including a single box of 20 does not help, as the required remainder (23) is also not a multiple of 3; and
3. more than one box of 20, complemented with boxes of size 6 or larger, obviously cannot lead to a total of 43 McNuggets.

Since the introduction of the 4-piece Happy Meal-sized nugget boxes, the largest non-McNugget number is 11. In countries where the 9-piece size is replaced with the 10-piece size, there is no largest non-McNugget number, as any odd number cannot be made.

### Other examples

In rugby union, there are four types of scores: penalty goal (3 points), drop goal (3 points), try (5 points) and converted try (7 points). By combining these any points total is possible except 1, 2, or 4. In rugby sevens, although all four types of scores are permitted, attempts at penalty goals are rare and drop goals almost unknown. This means that team scores almost always consist of multiples of try (5 points) and converted try (7 points). The following scores (in addition to 1, 2, and 4) cannot be made from multiples of 5 and 7 and so are almost never seen in sevens: 3, 6, 8, 9, 11, 13, 16, 18 and 23. By way of example, none of these scores was recorded in any game in the 2014-15 Sevens World Series.

Similarly, in American football, the only way for a team to score exactly one point is if a safety is awarded against the opposing team when they attempt to convert after a touchdown. As 2 points are awarded for safeties from regular play, and 3 points are awarded for field goals, all scores other than 1–0, 1–1, 2–1, 3–1, 4–1, 5–1 and 7–1 are possible.

## Applications

### Shellsort Time Complexity

The Shellsort algorithm is a sorting algorithm whose time complexity is currently an open problem. The worst case complexity has an upper bound which can be given in terms of the Frobenius number of a given sequence of positive integers.

### Least Live Weight Problem

Petri nets are useful for modeling problems in distributed computing. For specific kinds of Petri nets, namely conservative weighted circuits, one would like to know what possible "states" or "markings" with a given weight are "live." The problem of determining the least live weight is equivalent to the Frobenius problem.

### Terms in Expanded Power of a Polynomial

When a univariate polynomial is raised to some power, one may treat the exponents of the polynomial as a set of integers. The expanded polynomial will contain powers of $x$ greater than the Frobenius number for some exponent (when GCD=1), e.g. for $(1+x^{6}+x^{7})^{n}$ the set is {6, 7} which has a Frobenius number of 29, so a term with $x^{29}$ will never appear for any value of $n$ but some value of $n$ will give terms having any power of $x$ greater than 29. When the GCD of the exponents is not 1 then powers larger than some value will only appear if they are a multiple of the GCD, e.g. for $(1+x^{9}+x^{15})^{n}$ , powers of 24, 27, ... will appear for some value(s) of $n$ but never values larger than 24 that are not multiples of 3 (nor the smaller values, 1-8, 10-14, 16, 17, 19-23).