Write a recursive method that returns the value of N! (N factorial) using the definition given in this chapter. Explain why you would not normally use recursion to solve this problem.
What will be an ideal response?
```
public int factorial (int num)
{
int result;
if (num == 1)
result = 1;
else
result = num * factorial (num - 1);
return result;
}
```
You would not normally use recursion to solve this problem because it can be done more efficiently and because the recursive solution is no more intuitive than the iterative solution.
Computer Science & Information Technology
You might also like to view...
You can personalize your copy of Microsoft Office by clicking General settings in the Options group located in the ________ dialog box
A) Quick Access Toolbar B) Database Tools C) Show Actions D) Access Options
Computer Science & Information Technology
A(n) _______ is software for ODDs that allows disc images to be played/viewed through software
Fill in the blank(s) with correct word
Computer Science & Information Technology