A recursive function is given:
def mystery(n):
if n <= 0:
return 1
else:
return mystery(n-1) + mystery(n-2)
Find the value of mystery(4).
Solution :
The correct answer is 8.
To find the value of mystery(4), we can trace the recursive function step-by-step.
The definition of the function is:
For any input :
1. If , the function returns 1 (this is our base case).
2. Otherwise, for , the function returns:
Let us calculate the values starting from the smallest inputs up to 4:
Base Cases:
For any value less than or equal to 0, the function returns 1:
Step 1: Calculate mystery(1)
Step 2: Calculate mystery(2)
Step 3: Calculate mystery(3)
Step 4: Calculate mystery(4)
Thus, the value of mystery(4) is 8.
Completely free for students. Educators & coaching institutes get 2 months free Pro trial to create tests.
Access unlimited practice questions, detailed step-by-step solutions, and exam study materials — completely free for students.
Create and conduct professional online assessments with AI question generation, tab proctoring, and comprehensive batch management.
SSC CHSL Tier-1 Shift 1 2 July 2024 question paper with answers and detailed solutions. This practice paper covers questions from General Intelligence & Reasoning, General Awareness, Quantitative Aptitude, and English Language as asked in the SSC CHSL Tier-1 examination. Practice the SSC CHSL 2 July 2024 Shift 1 paper to understand the exam pattern, question types, difficulty level, and important topics for upcoming SSC CHSL exams.
SSC CHSL Tier-1 Shift 2 held on 2 July 2024 question paper with answers and detailed solutions. This previous year paper covers General Intelligence & Reasoning, Quantitative Aptitude, General Awareness, and English Language. The SSC CHSL Tier-1 exam was conducted in CBT mode with 100 questions for 200 marks and a 60-minute duration.
Copyright © 2026 Combe Labs Private Limited. All Rights Reserved.