Find the error(s) in the following recursive method, and explain how to correct it (them). This method

Question:

Find the error(s) in the following recursive method, and explain how to correct it (them). This method should find the sum of the values from 0 to n.
    public int sum(int n) {
    if (n == 0) {
    return 0;
    }
    else {
    return n + sum(n);
    }
    }

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  answer-question

Java How To Program Early Objects

ISBN: 9780134743356

11th Edition

Authors: Paul Deitel, Harvey Deitel

Question Posted: