Data Structures & AlgorithmsHardGATE CS · Codeforces Div2 B

What is the sum of lcm(a[i], a[i+1]) for consecutive pairs of the array [2, 3, 4, 6, 9]?

  1. A. 48
  2. B. 42
  3. C. 54
  4. D. 96

Correct answer: A. 48

The lcm of two values is a*b divided by gcd(a, b). Multiplying the two values without dividing by the gcd overshoots the answer.

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

Exams that ask this topic