0

# Consider the following function fdef f(m): if m == 0: return(1) else: return(m*f(m-1)) Which of the following is correct?

a) The function always terminates with f(n) = n b) The function always terminates with f(n) = factorial of n c) The function terminates for non-negative n with f(n) = n d) The function terminates for non-negative n with f(n) = factorial of n

7th Feb 2018, 2:45 AM
kamalesh vra + 2
It's a typical recursive function to compute factorials, but it doesn't take care of negative values. The answer would be d.
7th Feb 2018, 2:49 AM
Hatsy Rei + 4
Consider the following function f def f(m): if m == 0: return(1) else: return(m*f(m-1)) Which of the following is correct? The function always terminates with f(n) = n The function always terminates with f(n) = factorial of n The function terminates for non-negative n with f(n) = n The function terminates for non-negative n with f(n) = factorial of n tell a correct answer???
9th Feb 2018, 10:53 AM
S.Iswariya lakshmi 0
f(n)=factorial of n
9th Feb 2018, 10:58 AM
kamalesh vra 0
ans is d
8th Aug 2018, 9:28 AM
Sakthi Subash 0
Consider the following function f. 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 this program answer
16th Aug 2018, 4:36 AM 0
Consider the following function h. def h(n): f = 0 for i in range(1,n+1): if n%i == 0: f = f + 1 return(f%2 == 1) The function h(n) given above returns True for a positive number n whenever: n is a multiple of 2 n is a composite number n is a prime number n is a perfect square Tell me the above program answer
16th Aug 2018, 4:38 AM 0
composite no.
22nd Aug 2018, 5:59 AM
arpita halder 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
22nd Aug 2018, 6:03 AM
arpita halder 0
0 def f(m): if m == 0: return(0) else: return(m+f(m-1)) Which of the following is correct? Ans: The function terminates for non-negative n with f(n) = n(n+1)/2
23rd Aug 2018, 7:04 AM
Kanahaiya Kumar 