🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← 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)
  1. A.45
  2. B.55
  3. C.100
  4. 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 →