Question #224511

Consider the following function fpp.

def foo(m):
    if m == 0:
      return(0)
    else:
      return(m+foo(m-1))

Which of the following is correct?

 The function always terminates with f(n) = factorial of n

 The function always terminates with f(n) = n(n+1)/2

 The function terminates for non­negative n with f(n) = factorial of n

 The function terminates for non­negative n with f(n) = n(n+1)/2



Expert's answer

The correct answer is: The function terminates for non­negative n with f(n) = n(n+1)/2


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

LATEST TUTORIALS
APPROVED BY CLIENTS