Try sth like this:
bestsum = 0;
recurisve(index, sum){
if index > max_index{
if sum is better than bestsum{
bestsum = sum
}
}
recursive(index + 1, sum + element[index]);
recursive(index + 1, sum);
}
if sum is better than bestsum
should check all condition to determine if, having two results: sum
and bestsum
, bestsum
is better result than sum
.