Question DSA-DP-0003
EasyWhat is the output of this code?
a, b = 0, 1
for _ in range(10):
a, b = b, a + b
print(a)
- A.
34
- B.
55
- C.
Show answer and explanation
Answer: B
Bottom-up Fibonacci keeps only the last two values: F(10) = 55.
Popular companies
Prepare company by company
Hiring pattern, syllabus, past questions and mocks for each company.
All companiesPractice by subject
Dynamic Programming question
What is the output of this code?
a, b = 0, 1
for _ in range(10):
a, b = b, a + b
print(a)
34
55
Answer: B
Bottom-up Fibonacci keeps only the last two values: F(10) = 55.
89
21