EOS - dividend payout contract

hey, I am not a very experienced programmer but trying to learn as much as I can.

I have been going through the smart contract course for eos and was able to make my own token on a table.
I want to get the total number tokens distributed, not sure how to add up a total balance. Then (user_balance/total_balance) * eos_balance and then transfer eos according to the account.

Been trying to find some code to get a better idea about what i am doing, if anyone has ideas it would be appreciated.