+ 3
Consider the following function fdef f(m): if m == 0: return(1) else: return(m*f(m-1))
Which of the following is correct? 1)  The function always terminates with f(n) = n  2) The function always terminates with f(n) = factorial of n  3) The function terminates for non-negative n with f(n) = n  4) The function terminates for non-negative n with f(n) = factorial of n
7 Answers
+ 4
The trap is the infinite loop for negatives.
so the "always" answers are wrong.
since it is recursion 3) is wrong
4 is correct
+ 2
Thanks for suggestion...but it's a place where i can find answer for some of the question..
+ 1
Hey Tushar!
This section is the Q&A section, meaning if you have a question about coding, this is where it should be asked. It seems that you may just be posting quizzes, but you can make your own in the quiz factory so you should probably avoid doing so here.
Of course, if you are genuanly curious about the answer to the questions, you should try wording it in a way that actually asks people to help you out with it or that you may not understand a certain part, as opposed to just telling them to solve it.
Thanks!
+ 1
Also the answer is 4 ;)
0
I think function always terminate with return 1 whatever number you choose. So , i think answer 4 non-negative may be.
0
def f(m):
if m == 0:
return(0)
else:
return(m+f(m-1))
Which of the following is correct?
The function always terminates with f(n) = n(n+1)/2
The function always terminates with f(n) = factorial of n
The function terminates for non-negative n with f(n) = n(n+1)/2
The function terminates for non-negative n with f(n) = factorial of n
please tell me the answer
0
3rd option