I need to write several algorithms and one is giving me trouble. The one giving me issue requires the use of recursion to produce a summation for an integer. For example summation(4)=0+1+2+3+4=10.
The code I am working with is:
public long recursion(int N){
if (N <=1)
return 1;
else
return N + ________ ;
}
My question is the blank line above. How do I code the summation of N-1 to add to the value of N?