Question
1.
2.
3.
4.
Answer (Detailed Solution Below)
Option 3 : 48
Advertisement
Detailed Solution
सही उत्तर 48 है।
Key Points
Helpful?
Question:
What does the following Python recursive code output? / पुनरावर्ती निम्नलिखित Python कोड का आउटपुट क्या है? def f(n): if n <= 1: return 1 return n * f(n - 2) print(f(6))
1.
720
2.
120
3.
48
4.
24
Correct Answer: 48
f(6) = 6 x f(4) = 6 x 4 x f(2) = 6 x 4 x 2 x f(0) = 6 x 4 x 2 x 1 = 48. It is a double-step recursion, not a plain factorial. / f(6) = 6 x f(4) = 6 x 4 x f(2) = 6 x 4 x 2 x f(0) = 48। यह सामान्य फैक्टोरियल नहीं, दो-दो घटने वाली पुनरावृत्ति है।
Downloaded from PrepSnap (prepsnap.in)