How do I generate integer partitions?

前端 未结 7 1514
悲哀的现实
悲哀的现实 2021-01-20 04:54

I have a list of numbers like 1,2,3 and I want to find all the combination patterns that sum up to a particular number like 5. For example:

Sum=5
Numbers:1,2         


        
7条回答
  •  遥遥无期
    2021-01-20 05:39

    These are called the partitions of a number , and your problem seems to impose the constraint of which numbers you're allowed to use in the partition.

提交回复
热议问题