Explore BrainMass
Share

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

© BrainMass Inc. brainmass.com March 21, 2019, 2:35 pm ad1c9bdddf
https://brainmass.com/computer-science/security/recursive-method-127368

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.

$2.19