write a recursive method sum that calculates the sum of the integers between 1 and n, using the following recursive definition: The sum of the values from 1 to n is n plus the sum of the values from 1 to n-1. The method should have one parameter n.
public int sum ( int number ) { if ( number == 1 ) return 1; else return number + sum(number - 1); }
It's the equation that's confusing me, so If i were to hypothetically plug in number = 10, how would it return the sum of the integers exactly since return (10) + sum(10-1), in this case, what is sum? Sorry if i'm not making much sense, i'm a little confused on how to approach this one.