[Solved] An algorithm to find the exact amount to add to a top-up a card
The problem you describe is actually a very difficult problem in general, since it is related to the knapsack problem. But it is only hard if you allow very large amounts of money on the card and very many different prices. For your real world problem with very few different prices you can solve this … Read more