numbers. A pair of indices i < j is called lucky when the **first** digit of numbers[i] and the **last** digit of numbers[j] are coprime, meaning their greatest common divisor is 1.
Order matters: the first digit comes from the left number of the pair, the last digit from the right one.
Return the number of lucky pairs.numbers=[36, 15, 27] → 3
Pair (0, 1): 3 and 5 are coprime; (0, 2): 3 and 7 are too; (1, 2): 1 and 7 as well. That makes 3.
numbers=[42, 64, 8] → 0
The leading digits are 4 and 6 and the last digits are 4 and 8, so every pair shares the factor 2 and none count.
numbers=[19, 91] → 1
numbers=[36, 15, 27]
3
Run checks the first 3 tests in your browser. Submit checks all 69 tests on the server, hidden ones included.