In: Physics
tn = 10tn-1+1
where tn is the current term and tn-1 is the previous terms.
Write a Matlab function, which will receive t n-1 will calculate and return tn.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%a and b%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%a and b
t0=0;
n=10;
for i=1:n
tn=(10*t0)+1;
t0=tn;
fprintf("the value of function=%d\n",t0)
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%c%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%c
sum=0;
b=0;
while sum<12345
c=(10*b)+1;
b=c;
sum=sum+c;
fprintf("the sum of series is =%d\n",sum)
end
%%%%%%%%%%%%%%Results%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%the value of function=1
%the value of function=11
%the value of function=111
%the value of function=1111
%the value of function=11111
%the value of function=111111
%the value of function=1111111
%the value of function=11111111
%the value of function=111111111
%the value of function=1111111111
%the sum of series is =1
%the sum of series is =12
%the sum of series is =123
%the sum of series is =1234
%the sum of series is =12345