n=0
tn=1;
total=tn;
for n=1:nMax
    tn=tn*x/n;
    total=total+tn;
end
total