Khan.randRange(2, 10) n*(n+1)/2

Consider the following function:

public int exec(int n) {
  if (n == 0)
    return 0;	
  else
    return n + exec(n - 1);
}

What value does exec(n) return?
(Either write a number, or write "infinite recursion".)

ANS

By tracing this recursive function, you should find that the result is the sum of the integers from 1 to n.