Just want to be clear, this is practice, not homework.
I'm attempting to understand this a bit better...but I'm a bit lost as what to use for my test...and what exactly will help me get to the base case.
Here is what I have so far
public class int SumOddN (int ar[], int n)
if ar.length == 0 || ar == null || ar.lenth <= n)
{
return 0;
}
if ar[n] % 2 == 0
{
return SumOddN(ar,n-1);
else return SumOddN(ar,n+1)+ar[n];
}
}
public static void main(String[] args)
{
int ar[]= {0,1,2,3,4,5};
System.out.println(SummOddN(ar,2));
System.out.println(SummOddN(ar,3));
}
}