Explore BrainMass

recursive method

This content was COPIED from BrainMass.com - View the original, and get the already-completed solution here!

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;
return n + sum( n );
} // end method sum

© BrainMass Inc. brainmass.com March 21, 2019, 2:35 pm ad1c9bdddf

Solution Summary

It finds and corrects the erros in the recursive method. The response was rated '5/5' by the student who originally posted the questions.