% factorial computation and Taylor series to compute e=exp(1.0)
% e = 1 + 1 / 1!  +1 / 2!  + 1 /3!  + ... + 1 / n!
n=input('Term Order ');
a = [1 1:n];  % generate [ 1 1  2  3  4   ... n ]
a=cumprod(a); % generate [ 1 1! 2! 3! 4!  ... n!]
a = 1 ./ a;   % invert   [ 1/1 1/1! 1/2!  ... 1/n!]
a=sum(a);     % sum
disp(a);      % display
