Computer MOD
Compute the factorial function F(n) =! for an arbitrary nonnegative Integer n. n! 1…… (n-1). n = (n-1)!. n for n ≥ 1 and 0! = 0.1 by definition, from which of the following algorithms we can compute F(n) – F(n – 1)?
Explanation
Factorial is defined as: n! = n × (n - 1)! for n ≥ 1, and 0! = 1.
Recursive algorithm:
if n = 0 return 1else return F(n - 1) * nTo compute F(n) - F(n - 1), first calculate F(n) recursively using this formula, then subtract F(n - 1).
Last verified on 24-03-2026