The largest integer that cannot be made from fives and eights
What does the problem mean?
Problem. Find the largest integer that cannot be written as
For example, is representable, whereas is not. Repetition is allowed, and either count may be zero. The nonnegativity condition is essential: negative numbers of coins or summands are not permitted.
The answer is . We will prove both that is impossible and that every larger integer is possible.
An elementary method: use five columns
Arrange the positive integers in five columns, so moving down a column adds five.

Once a number in a column is representable, every number below it is representable by adding another five. The multiples of eight give a starting point in each residue class modulo five:
Their residues are , so they cover all five columns. These are the smallest representable numbers in their respective columns: using five changes no residue, and the least nonnegative count of eights for each residue is one of .
The last unrepresentable numbers before those starting points are, by residue class ,
The negative entry simply means every nonnegative multiple of five is already representable. The largest nonnegative obstruction is .

A short alternative using five consecutive values
The five integers immediately after are all representable:
Adding any number of fives proves that every integer at least is representable.
For , reduction modulo five requires , or . A nonnegative such is at least four, making . Thus is impossible, completing the proof.
The Diophantine viewpoint
Without the restrictions , every integer can be written as , because . One solution for is , and every integer solution is
The problem asks whether the integer can be chosen so that both coordinates are nonnegative. This is a bounded-feasibility question, not merely whether a linear integer equation has a solution.
The general parameterization is explained in Diophantine equations.
The general two-denomination formula
Let be coprime positive integers. The largest integer not representable as with nonnegative integers is
Here is a proof, so the formula need not be memorized without its conditions.
The proposed largest obstruction is impossible
Set . If with , then modulo ,
Since are coprime, , so . But then
contradicting with .
Every larger integer is possible
Take . The residues of modulo are all distinct, by coprimality. Choose with . Then is an integer, and
Thus , and since is an integer, . This constructs a valid representation of every .
For , the formula gives . If the denominations are not coprime, infinitely many integers fail divisibility and there is no largest obstruction. If one denomination is one, every nonnegative integer is representable. Those cases must be separated from the theorem.
Related articles
- Equating rational and irrational parts: proof and worked problems
- How to simplify nested square roots, with three worked examples
- Conditional probability: the formula, information protocols, and worked examples
- Integration by parts: formulas, proof, and four useful patterns
- Triple-angle identities: remember, derive, and apply them
About the author
Koki Saito
Physician and graduate of the University of Tokyo Faculty of Medicine. Drawing on his entrance-exam experience, he explains how to choose mathematical methods and construct complete solutions.
Full profile →Have a question or spotted an error? Contact us.