While not always optimal, you can design your algorithm so that it always returns the largest coin possible until the value of the change is met.