Just one corrction the function findASolution should look like this:

static void findASolution(currentIndex){
       if(curentSum>=Sum) {
             return;
       }
      currentlyTakenSums[currentIndex] = 1;
      double sumToAdd = givenSums[currentIndex];
      curentSum += sumToAdd;

      if(curentSum>Sum && curentSum<=Sum+Tolerance ){
              //found a Solution
              currentTolerance = curentSum -Sum;
              if( currentTolerance < SolutionTolerance){
                   //found a better solution
                    copyCurentSolution();
              }
      }
       if(curentSum<Sum && currentIndex<givenSums.size - 1){
           findASolution(currentIndex +1);
       }
      curentSum -= sumToAdd;
      currentlyTakenSums[currentIndex] = 0;
       if(currentIndex<givenSums.size - 1){
           findASolution(currentIndex +1);
       }
}

Reply via email to