Here's an example code to calculate how long it will take for a certain amount to accumulate with annual additional deposits and interest:
main.m723 chars23 lines
This code uses a while loop to repeatedly add the annual deposit and interest to the current amount, until the target amount is reached. The number of years passed is also updated every iteration.
gistlibby LogSnag