How do you calculate the closing inventory?

Apply the inventory control formula: Cost of sales = Opening inventory plus Net purchases ( Purchases + carriage on purchases + customs duty – purchases returns) less closing inventory.

So, if you change the subject of the formula : Closing inventory = Opening inventory plus Net purchases less Cost of sales