The largest unmakeable total

A vending machine accepts only two chip denominations, worth 4 and 7 credits, and you may use any number of each (including none). Many totals — like 5 or 17 — cannot be paid exactly. What is the largest total (in credits) that cannot be formed as a non-negative combination of 4s and 7s?

Show hints (2)+
  1. Sort totals by their residue mod 4; within a class, adding 4s covers everything above the entry point.
  2. The entry point of each class is set by how many 7s you need to reach that residue.

Answer

Reveal answer →

17

Want the full step-by-step worked solution? It's part of Premium — along with a worked solution for every question in the bank.

Asked at: Jane Street, Optiver

Related questions