I have a smart contract that keeps record of the people holding the tokens in form of array of addresses. An owner of the smart contract, whenever, sends some ethers to the contract these ethers shall be divided among all token holders depending on how much they hold the tokens and accordingly these fund will be divided. We will allocate the funds to each holder in a form of mapping and once they want to redeem the pending reward will be sent to them.
My code is currently using a for loop to divide the received deposit among all token holders by iterating over the complete array of holders.Since using loop will eventually goes out of gas limit, so what should be the suggested approach here? How can we divide an amount among all token holders without looping/much gas?