Finding the smallest number in a given ratio