X267: Recursion Programming Exercise: Cumulative Sum

For function sumtok, write the missing recursive call. This function returns the sum of the values from 1 to k.

Examples:

sumtok(5) -> 15

Your Answer:

x
 
1
public int sumtok(int k) {
2
  if (k <= 0) {
3
    return 0;
4
  } else {
5
    return <<Missing Recursive case action>>
6
  }
7
}
8
Reset

Practice a different Java exercise

Feedback

Your feedback will appear here when you check your answer.