I\'m working through an interview question that goes like:
Given an array of integers and sum, check whether any combination adds up to the sum.>
That sounds like a classic recursion problem. You start with the first element and consider the rest of the array; for each element, either it is picked or it isn't. The base case is when the start index is greater than the length of the array. Something like
public static bool canSum(int start, int[] array, int sum)
{
if (start >= array.Length)
return sum == 0;
return canSum(start + 1, array, sum - array[start]) || canSum(start + 1, array, sum);
}