Loading the task…
Sometimes you need to check pairs of elements against a simple rule, like whether their sum divides evenly by a number. The function divisible_sum_pairs receives a list ar and an integer k. Count the pairs of indices (i, j) where i < j and ar[i] + ar[j] is divisible by k with no remainder.
[1, 2, 3, 4, 5, 6], 53[1, 3, 2, 6, 1, 2], 35[1, 2, 3, 4, 5, 6], 35def divisible_sum_pairs(ar: list[int], k: int) -> int:
Sign in to see submission history
Sign inSign in to use AI Mentor
Sign in[1,2,3,4,5,6], 53[1,3,2,6,1,2], 35[1,2,3,4,5,6], 35[2,2,2,2], 26[1], 20[1], 70