I'm looking for advice on how to find all possible sums of N elements. For example, I have an array
int []arr={91,58,89,87,25,65,21};
For some int n=3;
I need to find all possible sums of 3 elements in this array. In the beginning, it looked easy for me as I would find all sums of subarrays of size 3 but I am not sure of subsequences of size 3 . I found similar questions on Google and the solution was to use recursion. I'm not sure I really understand how to solve this one with my conditions, hope you could give me an advise and example so I could solve this one! I'm not sure my initial code is need since it works linearly.
Thank you in advance.