I have a random integer $n$ and another integer called the summary. I want to know how many ways I can sum a subset of numbers from $1$ to $n$ to produce the value of summary.
For example, I have $1,2,3,4,5,6,7,8,9,10$ and the summary is $18$. The expect result is:
- $10 + 8$
- $6 + 4 + 8$
- $1 + 2 + 3 + 4 + 8$
Is there any algorithm or formula for this problem?