I'm writing software and I'm trying to calculate interest on a principal value that changes daily in a predictable way. For example, if you saved $5 each day for five years at a 4% annual interest rate.
I can brute force this calculation, but I imagine there's a better way, which I'm just not aware of. What's the best way to calculate the final principal + interest for the above example?