Function which returns a random number in the given range