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

```
static int Sum(int n)
{
if (n == 0)
{
return 0;
}
else
{
return n + Sum(n);
}
}
```


The method never reaches the base case. The recursion step should be:
return n + Sum(n - 1);

Computer Science & Information Technology

You might also like to view...

The ________ is the left border of a chart with the value labels

A) plot area B) horizontal axis C) vertical axis D) grid area

Computer Science & Information Technology

Office 2013 enables you to save files to SkyDrive or your computer. Why might it be helpful to save a file in both locations?

What will be an ideal response?

Computer Science & Information Technology

If you want to delete an entire task row, you can select the entire row and then press the ____ key.

A. F1 B. Esc C. Ctrl D. Delete

Computer Science & Information Technology

The detailed design report contains all of the following except

A. input screen formats B. alternative conceptual designs C. report layouts D. process logic

Computer Science & Information Technology