Say I have an array of integers:
arr = [0,5,7,8,11,16]
and I have another integer:
n = 6
I need a function that rounds down to the nearest number from the array:
foo(n) #=> 5
As you can see, the numbers do not have a fixed pattern. What's an elegant way to do this?
Thanks