Advertisement
libdo

Untitled

Nov 4th, 2017
7,211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public static int getAllSums(int array[], int startingValue, int pos, int target){
  2.  
  3. int random = 0;
  4. int sum1 = random;
  5.  
  6. for (int i = pos; i < array.length; i++)
  7. {
  8. int currentValue = startingValue + array[i];
  9.  
  10.  
  11.  
  12. if(currentValue%target == 0) {
  13.  
  14. array[i] = 0;
  15. sum1 = random + currentValue;
  16.  
  17. return sum1;
  18. }else {
  19.  
  20. getAllSums(array, currentValue, i + 1, target);
  21.  
  22. }
  23.  
  24. }
  25. return 0;
  26.  
  27.  
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement