Data Structures & AlgorithmsVery hardGATE CS · Codeforces Div2 B

What is the smallest x such that lcm(1, 2, ..., x) exceeds 1,000,000?

  1. A. 17
  2. B. 16
  3. C. 20
  4. D. 10

Correct answer: A. 17

The lcm only grows at prime powers: lcm(1..16) = 720720 is still below 10⁶, and multiplying by the prime 17 gives 12252240. Answering 16 is the off-by-one, 20 confuses it with 2^x > 10⁶, and 10 with 10! > 10⁶.

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

Exams that ask this topic