A function which takes 2 parameters: an array of whole numbers and an integer X.
The function looks for pairs of numbers in the array which sum to X. Each array element can only be used in one pair. The function returns the count of how many such pairs it finds.
I have assumed that the array passed to the function has already been sorted in ascending order.