2. Multiplying Factors
For a pair of integers (x, y) and an integer k, the
multiplying factor is defined as minimum positive
integer m such that LCM(x, y) * m is divisible by
k. Here LCM(x, y) represents the smallest positive
integer divisible by both x and y, their least
common multiple.
Given an array arr of n integers and an integer
k, find the sum of multiplying factors over all pairs
of integers (arr[i], arr[j]) and k 0?i, j<n.
Example
Suppose n = 3, arr = [4, 5, 6] and k = 12.
Pair Multiplying
Factor Remarks
(4, 3 LCM(4, 4) * 3 = 4 * 3
4) = 12
(5, 12 LCM(5, 5) * 12 = 5 *
5) 12 = 60
(6, 2 LCM(6, 6) * 2 = 6 * 2
6) = 12