Given a set size $n$ consisting of elements from $1->n$, choose $k$ elements from the set such that their summand equals $S$.
For ex: $n = 5 = \{1,2,3,4,5\}$ , $k = 3$ and $S=9$ then elements chosen are $1,3$ and $5$
So is there a general formula or a general approach on how to choose such elements? because n and k can be really large.
You can give me the gist or go ahead.
An hacky solution:
for bigger lists: