I have a program that I\'m trying to make for class that returns the sum of all the integers in an array using recursion. Here is my program thus far:
public
private static int sum(int[] arr) { // TODO Auto-generated method stub int n = arr.length; if(n==1) { return arr[n-1]; } int ans = arr[0]+sum(Arrays.copyOf(arr, n-1)); return ans; }