Mathematically, the problem can be formulated as follows:
This problem can be solved by brute force search or backtracking with maximum time proportional to |V |m, where |V | is the number of distinct stamp values allowed. Therefore, if the capacity of the envelope m is fixed, it is a polynomial time problem. If the capacity m is arbitrary, the problem is known to be NP-hard.3
"Art of Problem Solving". https://artofproblemsolving.com/wiki/index.php/Chicken_McNugget_Theorem ↩
Jeffrey Shallit (2001), The computational complexity of the local postage stamp problem. SIGACT News 33 (1) (March 2002), 90-94. Accessed on 2009-12-30. https://arxiv.org/abs/math.NT/0112257 ↩