# Finding the largest integer that cannot be partitioned in a certain way

I want to use Mathematica to solve the problem:

Find the maximum $k$ such that $6x+9y+20z=k$ does not have a non-negative solution.

I tried FrobeniusSolve. But what is the elegant way to find the maximum?

I know the theoretical background of this problem, and I know other ways of getting the solution. But I want to see how this can be done elegantly in Mathematica.

-
I'm not sure I understand this. If positive x, y, z are a solution for a given k, then nx, ny and nz are a solution for nk. So it seems to me there is no maximum k. – Sjoerd C. de Vries May 28 '13 at 20:35
@SjoerdC.deVries it is expected that there are infinitely many k that have a solution. In fact the question seem to assume that for some N, all k>N have solutions. We wish to find the smallest such N. That is the same as to say, we wish to find the largest k that does not have a solution. I think. – Jacob Akkerboom May 28 '13 at 20:43
The short answer to this question is to use FrobeniusNumber[{6, 9, 20}]. – Jacob Akkerboom May 28 '13 at 20:53
mathworld.wolfram.com/CoinProblem.html if you want to implement something yourself. There is a downloadable notebook. – Jacob Akkerboom May 28 '13 at 20:56
@JacobAkkerboom I guess we're reading different things in the question and I'm afraid I don't see any grounds for your interpretation based on the literal text of the question. The question asks for a maximum k and I feel it's pretty clear there can generally not be a maximum k. – Sjoerd C. de Vries May 28 '13 at 20:58

You should use FrobeniusNumber instead of FrobeniusSolve, since it serves this purpose

The Frobenius number of $a_{1}, ... a_{n}$,.is the largest integer b for which the Frobenius equation $a_{1} x_{1}+ ... a_{n} x_{n} = k$ has no non-negative integer solutions. The $a_{i}$ must be positive integers.

FrobeniusNumber[{6, 9, 20}]

43


Nevertheless you can still get the result playing with FrobeniusSolve, there might be many possible ways, let's point out one of them using Cases with an appropriate replacement rule e.g.

Max @ Cases[ Table[{ k, FrobeniusSolve[{6, 9, 20}, k] != {}}, {k, 100}], {a_, False} -> a]

43


In case of not knowing FrobeniusNumber, one can get an idea also with Reduce or Solve although these ways are not recommended for diophantine equations, see e.g. Finding the number of solutions to a diophantine equation.

-
That looks good, I am glad you did it, I will go to sleep :). – Jacob Akkerboom May 28 '13 at 22:26
I'd use FindInstance in preference to Reduce, for the particular task of deciding existence (of solutions). – Daniel Lichtblau May 28 '13 at 22:46
@Artes Yeah, no surprise the quantifier elimination would need either infinite time or memory, and possibly both. – Daniel Lichtblau May 29 '13 at 0:00