Proofs of Universal Statements: Mathematical Induction · Base of Induction
Lesson 4
Let us prove that any integer \(m \ge 8\) can be represented as a sum of threes and fives, by induction on \(m\). First, let's verify that we can change \(m=8,9,10\): \[8=5+3,\ 9=3+3+3,\ 10=5+5.\] This means we can also change \(m=11,12,13\): \[11=8+3,\ 12=9+3,\ 13=10+3,\] and we already know how to change \(8,9,10\). Then, we can also change \(m=14,15,16\), because \[14=11+3,\ 15=12+3,\ 16=13+3.\] And so on. As we see, the base of induction here considers three cases instead of one, and the step is treated slightly differently (instead of \(m \to m+1\) we use \(m \to m+3\)).
The corresponding reasoning can easily be transformed into a recursive algorithm. And this is not surprising: induction and recursion are almost the same thing.
base_cases = {8: [5, 3], 9: [3, 3, 3], 10: [5, 5]}
def change(amount):
assert amount >= 8
if amount in base_cases:
return base_cases[amount]
return change(amount - 3) + [3]
print(change(28))[5, 5, 3, 3, 3, 3, 3, 3]
For the curious 🤓
def change(a):
return ([5, 3], [3, 3, 3], [5, 5])[(a - 8) % 3] + [3] * ((a - 8) // 3)
The largest number \(g(a_{1}, \dotsc, a_{n}) \in \mathbb{Z}\) that is not contained in \(S\) is called the Frobenius number. There are many natural questions about this quantity. For the curious 🤓
We know the answer to the first question, but we can fully answer the second and third questions only for \(n=2\). For \(n>2\) the problem of finding the Frobenius number is already NP-hard.