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

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

relerr = 1.0e-14;

expx = 1;
term = 1;

for k = 1:10000
  term = term * x / k;
  expx = expx + term;
  if (abs(term) < (expx * relerr))
    kfinal = k;
    break;
  end
end

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

