Ah! I see now that the goal was to update the score as coins are collected. Before, I thought the original poster was asking a question like, “Given n coins, how do I calculate what the score is?”
That’s where my suggestion came from. In pseudocode, the answer would be:
score = floor( coins / 20 )
Anyway, given the original poster’s intent, your suggestion is definitely better.