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]?
- A. 48
- B. 42
- C. 54
- 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.
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 in the range 1 to 1000 are divisible by 3 and have a digit sum divisible by 7?
- How many contiguous subarrays of [3, 4, 1, 2, 5, 6] have a sum divisible by 5?
- How many pairs i < j with 1 <= i, j <= 12 have i times j divisible by 12?
- What is the value of the sum of floor(20 / i) for i = 1 to 20?
- A bubble sort performs left-to-right passes, swapping adjacent elements that are out of order, and stops after the first pass in which no…
- Six people stand in a circle numbered 1 to 6. Starting from person 1, every 4th person (counting the start as 1) is removed until one…