计算机编程!!计算多项式的值:exp(x)=1+x+x^2/2!+x^3/3!+.......+x^i/i!(绝对值x^i/i!<=10^-10)

来源:百度知道 编辑:UC知道 时间:2024/05/09 12:52:47
用pascal
快点,谢.

var a,b:qword;i,x:integer;c,t,s:real;
begin
readln(x);
t:=1;
for i:=1 to 10 do
t:=t/10;
a:=1;b:=1;s:=1;i:=0;c:=1;
while c>=t do
begin
i:=i+1;
a:=a*x;
b:=b*i;
c:=a/b;
s:=s+c;
end;
writeln(s);
end.

var i,X:integer;
t,s:real;
begin
readln(x);
i:=0; t:=1; s:=1;
while abs(t)>1e-10 do
begin
i:=i+1;
t:=t*x/i;
s:=s+t;
end;
writeln('EXP(',X,')=',S:0:4);
readln;
end.