You might combine 6 and 9 to get 15, but it's impossible to get 16, or 17 and so on. Is there a largest number you can't achieve by adding some combination of only these 3 numbers? If there's not how do you prove it?
Is there a largest number that is impossible to achieve by combining 6s, 9s and 20s?
-
0You might want to make the post and the title match on the numbers ($15$ or $20$ ?) and also perhaps precise what you mean by "combine". – 2017-02-08
3 Answers
These are the "non-McNugget numbers", of which the largest is 43.
-
0how would you justify that answer? – 2017-02-08
-
0@plantondi there is a light generalization known as "the frobenius number" in what is typically known as the "coin problem." There are efficient algorithms for when there are only three numbers, as is the case for the mcnugget problem, but it is an NP hard problem in general. – 2017-02-08
Sure, this is the Frobenius coin problem, effectively with $3$ and $20$, giving the answer $37$. (The $3$ is a combination of the $6$ and $9$ coins for numbers greater than $3$).
EDIT... My oversight - $43$ does not work. This is because the $(6,9)$ combination cannot produce a value of $3$, so when we can have $2$ $20$-value coins to allow the total to reach values that are $\equiv 1 \bmod 3$, there is still (only) one larger value in this congruence class that cannot be reached, $43$.
-
043 is not expressible as a linear combination of $\{ 6,9,20 \}$. – 2017-02-08
-
0@SAWblade, thanks, I added some discussion on this – 2017-02-08
Consider the following cases:
- $A_{44}=\{6,6,6,6,20\}$
- $A_{45}=\{6,6,6,6,6,6,9\}$
- $A_{46}=\{6,20,20\}$
- $A_{47}=\{6,6,6,9,20\}$
- $A_{48}=\{6,6,6,6,6,6,6,6\}$
- $A_{49}=\{9,20,20\}$
- $A_{n+6}=A_{n}\cup\{6\}$
So every $n\geq44$ can be represented as a sum of $6$s, $9$s and $20$s.
Now you just need to show that $43$ cannot, and you're done.
Here is a short Python script for asserting this:
def func(val,arr):
if val > 0:
for k in arr:
if val >= k and func(val-k,arr):
return True
return val == 0
print func(43,[6,9,20])