%
%                            k
%                     inf   x
% Cálculo de exp(x) = SUM  ----
%                     k=0   k!
%

x = input('Entre el exponente x: ');

relerr = 1.0e-13;

expx = 1;
term = 1;

k = 0;
while (abs(term) >= (expx * relerr))
  k = k + 1;
  term = term * x / k;
  expx = expx + term;
end
kfinal = k;

fprintf('\nexp(%g) = %g\n', x, expx);
fprintf('Se evaluaron %d términos\n', kfinal);

