Answer the question
In order to leave comments, you need to log in
How to decompose a number into a sum of other numbers?
Greetings!
The question is: For example, there is a set of numbers (2, 3, 4, 5, 6) and some arbitrary number such that n >=2. So, you need to decompose this number into the sum of the above (they can be repeated in the original set).
Example: the number 7 can be decomposed as 3 + 4. The number 9 as 5 + 4. The number 11 can be decomposed as 5 + 4 + 2.
Are there such algorithms? Well, an example in any language, if any, is very welcome.
Answer the question
In order to leave comments, you need to log in
This is called the knapsack packing problem. Further - in Wikipedia.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question