How to calculate average price in share

Do you want a formula using total investment and quantity bought?