title: index of closest a number in array, closest to x, that cannot be larger than x
body: <p>How can I write a function that accepts an array of integers and an integer x and returns the index of the integer in the array that is closest to x argument without being larger than x.  If all are above x, the function will return negative one.  Assuming two or more numbers cannot be the same in array.</p>