Data Structures & AlgorithmsHardGATE CS · TCS NQT

What is the largest n such that 1 + 2 + ... + n does not exceed 1000?

  1. A. 45
  2. B. 44
  3. C. 46
  4. D. 48

Correct answer: B. 44

44 * 45 / 2 = 990 is within the limit, but 45 * 46 / 2 = 1035 exceeds it.

More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions

Exams that ask this topic