MATLAB: How many laps a runner can make for 45 minutes with increasing 10% of running time in each lap

homeworkwhile loop

Hello,
I would like to write a program to calculate how many laps a runner can make for 45 minutes with 10% increase of his or her running time in each lap.
The runner run the first lap in 1 minute.
Here is what I have.
lapcounter=1;
running_time=1;
runningtime_total=0;
runningtime_allowed=45;
number_lap=0;
while lapcounter<=runningtime_allowed
lapcounter=lapcounter+(lapcounter*0.10);
running_time=lapcounter+(lapcounter*0.10);
runningtime_total=running_time+(running_time*0.10);
disp("Time: " + runningtime_total);
number_lap=number_lap+1;
end
disp("Number of lap: " + number_lap);
I think I get the idea of how to calculate running time in each lap like running time = lap time*(lap time*0.10), but I need to add the time the runner has been running so that I can know how many laps he or she can make for 45 minutes.
I appreciate your response in advance.

Best Answer

function laps=runTrack(t,dt,rt)
%first lap time: t
%total run time: rt
%percent increase in each lap: dt
M=cumsum(t*((1+dt)*ones(1,100)).^(0:99));%pick a number of laps that will not be exceeded (I chose 100)
laps=find(M<=rt,1,'last');
end
The output (laps) gives the total number of laps the runner can complete in rt minutes when the runner's first lap time is t, and it increases by dt each lap.