Let's say I have an initial capital of $X$ deposited in a bank with interest rate $Y$. The interest is payed out in cash daily so I need to deposit them periodically to get compound interest, however the bank charges a fixed fee $Z$ each time I make a deposit.
Initially I thought there's an optimal period that I could just stick to so I brute forced my calculation in Excel, but I soon found that I should deposit more frequently when my account grows larger since the fee will become insignificant as my fund increases. The benefit of this becomes much more significant when I have an high interest rate and longer time period/high fee. This is where I got stuck because of the recursive calculation.
My question is how to find the optimal schedule for depositing.