Data Structures & AlgorithmsModerateTCS NQT · Infosys

Problem: In the sequence 2, 3, 5, 8, 12, 17, … each term increases by one more than the previous increase (differences 1, 2, 3, 4, …). What is the 8th term?

  1. A. 30
  2. B. 38
  3. C. 37
  4. D. 23

Correct answer: A. 30

Term 8 = 2 + (1 + … + 7) = 30. Adding increments up to 8 gives the 9th term 38, starting increments at 2 gives 37, and stopping at 6 gives the 7th term 23.

More Coding Interview Problems questions

Exams that ask this topic