% Simple implementation of the exp() function w/o
% computing the x^i and the i! explicitely
% and termination when convergence is detected
% using break
% Minas Spetsakis, Feb. 2018

xx = 2.2;

trm = 1.0;
expres = 1.0;

for i=1:100
    trm = trm*xx/i;
    if abs(trm)<eps(expres)
        fprintf('stopped at %d\n',i);
        break;
    end;
    expres = expres + trm;
end;

expres
