values and an integer divisor.
Count the index pairs i < j for which the product values[i] · values[j] is divisible by divisor.
Checking every pair is too slow here; think about what actually matters in each number.values=[3, 4, 6, 9], divisor=6 → 5
The pair products are 3·4 = 12, 3·6 = 18, 3·9 = 27, 4·6 = 24, 4·9 = 36 and 6·9 = 54. Only 27 is not divisible by 6, so the answer is 5.
values=[5, 7, 11], divisor=3 → 0
None of the numbers is divisible by 3, so no product is either.
values=[2, 2], divisor=4 → 1
Neither number is divisible by 4 on its own, but their product 4 is.
values=[3, 4, 6, 9], divisor=6
5
Run checks the first 3 tests in your browser. Submit checks all 104 tests on the server, hidden ones included.