Let's do a simple table to help us to solve it:
Therefore, for the first 5 bags, the cost would be 5 multiplied by 3 (cost of each bag), the total cost would be $15 for the first 5 bags, after that the cost would increase by 1 dollar per bag, therefore for 6 bags it would cost 16, 7 would be 17 and 8 is 18.