Working out the formula for the prices