The revenue from selling items is , and the total cost is . Write a function that gives the total profit earned, and find the quantity which maximizes the profit.

Profit

Quantity maximizing profit

You can earn partial credit on this problem.