Hello,
Place the values in an array
Calculate the difference with nbr1 and nbr 2
Remember the difference
In a loop Calculate each other difference (1 and 3, 1 and 4 etc)
If there is a smaller difference than nbr1 and nbr2 then rember the new nbr and the difference.
And so on.
If you compared all differences then you should get the closest nbr.