Solved

Which Algorithm Segment Completes the Definition for an Iterative Version

Question 2

Multiple Choice

Which algorithm segment completes the definition for an iterative version of the factorial function?
Int factorial_i (int n) {
Int result = 1;
/** missing code inserted here */
__________
Return result ;
}


A) if (n == 0)
return 1;
else if (n > 0)
return n * factorial_i(n - 1) ;
else
B) if (n == 0)
return result;
else if (n > 0)
return n * factorial_i(n - 1) ;
else
C) for (int i = 1; i <= n; i++)
result *= i;
D) for (int i = 1; i <= n; i++)
n *= i;

Correct Answer:

verifed

Verified

Related Questions