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
kamalesh vra - avatar
10 Respuestas
+ 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
Hatsy Rei - avatar
+ 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
S.Iswariya lakshmi - avatar
0
f(n)=factorial of n
9th Feb 2018, 10:58 AM
kamalesh vra
kamalesh vra - avatar
0
ans is d
8th Aug 2018, 9:28 AM
Sakthi Subash
Sakthi Subash - avatar
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
prasad naidu
prasad naidu - avatar
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
prasad naidu
prasad naidu - avatar
0
composite no.
22nd Aug 2018, 5:59 AM
arpita halder
arpita halder - avatar
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
arpita halder - avatar
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
Kanahaiya Kumar - avatar
0
def mys(m): if m == 1: return(1) else: return(m*mys(m-1)) Which of the following is correct? The function always terminates with mys(n) = factorial of n The function always terminates with mys(n) = 1+2+...+n The function terminates for non-negative n with mys(n) = factorial of n The function terminates for positive n with mys(n) = factorial of n
30th Jan 2024, 3:03 PM
Manikanta