← Quiz: Solving Recurrences: all 15 questions
Quiz: Solving Recurrences · Question 13 of 15
What does this print? (code)
What does this print?
a = 0
for n in range(1, 11):
a = a + n
print(a)
- A.45
- B.55
- C.100
- D.110
Answer & explanation
Correct answer: 55
Unrolling aₙ = aₙ₋₁ + n with a₀ = 0 gives n(n + 1)/2 = 55 for n = 10.
Can you get the rest right without peeking?
Take the timed Quiz: Solving Recurrences quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →