Given a set size $n$ consisting of elements from $1 \rightarrow n$, choose $k$ elements from the set such that their summand equals $S$, if possible
For ex: $n = 5$ (i.e the choices $\{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.
Well, you can first deduce that $S \in \left[1, \frac{n(n+1)}{2}\right] \subset \mathbb{N}.$ Then for an $S$ in this discrete interval the formula you seek would be the partitions of $S$ into $k$ distinct parts less than or equal to $n$, for which I believe there is no closed form formula, but looking into partitions may get you more information. There may be a generating function for this but I am not positive.
There is discussion of the generation function for partitions of $S$ into just distinct parts here The number of partitions of $n$ into distinct parts equals the number of partitions of $n$ into odd parts but partitions of $S$ into $k$ distinct parts all less than or equal to $n$ would certainly require more work.