Data Structures & AlgorithmsVery hardGATE CS · Codeforces Div2 B
What is the smallest x such that lcm(1, 2, ..., x) exceeds 1,000,000?
- A. 17
- B. 16
- C. 20
- 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⁶.
Practise more Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questionsArrays, Strings, Linked Lists, Stacks, Queues and Hashing: notes and key points
More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions
- How many integers x with 1 <= x <= 100 satisfy x^2 mod 24 = 1?
- How many ordered pairs (i, j) with 1 <= i, j <= 18 have i j divisible by 18?
- How many contiguous subarrays of [2, 8, 3, 3, 2, 6] have a product that is a perfect square?
- How many contiguous subarrays of [1, 3, 2, 6, 4, 2] have a sum divisible by their length?
- Evaluate the integer expression 2 - 3 4 + 10 / 3 using standard precedence and integer division that truncates toward zero. What is the…
- What is the length of the longest run of consecutive integers (in any order) present in the array [9, 1, 4, 7, 3, -1, 0, 5, 8, -1, 6]?