Skip to content

Commit

Permalink
Update P01_RecursiveArraySum.java
Browse files Browse the repository at this point in the history
  • Loading branch information
svetlanasieber authored May 28, 2024
1 parent cf9c12d commit e9bdf41
Showing 1 changed file with 0 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,4 @@ public static int sumArray(int [] array, int index) {
}
}

/* import java.util.Arrays;
import java.util.Scanner;
public class P01_RecursiveArraySum {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);

int[] array = Arrays.stream(scanner.nextLine().split(" "))
.mapToInt(Integer::parseInt)
.toArray();
System.out.println(sum(array, 0));
}
private static int sum(int[] array, int index) {
if (index == array.length - 1){
return array[index];
}
return array[index] + sum(array, index + 1);
}
} */

0 comments on commit e9bdf41

Please sign in to comment.