Instead of trying to find the minimum number of coins to changeM cents,
we attempt the superficially harder task of doing this for each amount of
money, m, from 0 to M. This appears to require more work, but in fact, it
simplifies matters. The following algorithm with running time O(Md) calculates
bestNumCoinsm for increasing values of m. This works because the
best number of coins for some value m depends only on values less than m.