1
$\begingroup$

Problem: Given a number $n,$ we want to find out the subsets of $\{1,2,\ldots,n\}$ that add up to the given number $n.$

Example: If $n=6,$ then the output is: $\{1,5\}, \{2,4\}, \{1,2,3\}.$

Can anyone suggest a program for this?

  • 0
    You mean subsets of {1,2,...,N} right? Numbers don't have subsets.2012-03-27
  • 0
    What about $\[ 3,3 \]$? Are repetitions allowed?2012-03-27
  • 0
    So you don't want to include $[1,1,4]$ or $[3,3]$ then? In that case what you want is called "[partitions of an integer](http://enwp.org/Integer_partition) into distinct parts".2012-03-27
  • 0
    see here: [Partitions](http://en.wikipedia.org/wiki/Partition_%28number_theory%29)2012-03-27
  • 0
    Did I edit too much?2012-03-27
  • 0
    [Ordered partitions of an integer](http://math.stackexchange.com/q/117489/19341)...2012-04-05

2 Answers 2