Difficulty: Easy
Correct Answer: Fibonacci
Explanation:
Introduction / Context:
This classic loop prints a well-known series by repeatedly summing the previous two numbers. Your goal is to recognize the update pattern and map it to the correct series name without getting distracted by variable names.
Given Data / Assumptions:
Concept / Approach:
These assignments implement the Fibonacci recurrence where next = previous + current. The variable j holds the value that is printed, then the pair (i, j) is advanced to the next two Fibonacci numbers via the rotation j = i; i = val. The sequence begins 1, 1, 2, 3, 5, 8, 13, 21 … and stops before the next term would make i ≥ 25.
Step-by-Step Solution:
Verification / Alternative check:
Compare to the canonical Fibonacci series start: 1, 1, 2, 3, 5, 8, 13, 21 — matches exactly.
Why Other Options Are Wrong:
Prime/palindrome/odd/even classification does not fit this two-term additive recurrence.
Common Pitfalls:
Confusing which variable prints vs which advances; reading “i < 25” as a print limit instead of the control for advancing.
Final Answer:
Fibonacci
Discussion & Comments