Toggle navigation
Home
Latest pastes
FAQ
Random
Register
Login
Untitled
SUBMITTED BY:
Guest
DATE:
May 10, 2015, 4:38 p.m.
FORMAT:
Text only
SIZE:
557 Bytes
Raw
Download
Tweet
HITS:
772
Go to comments
Report
Tính tổng sau
S= 1/i! với i chạy từ 0 đến n
Giải :
Ta viết hàm tính giai thừa
sau đó tính tổng.
Hàm giai thừa là
f(x)= x*(x-1)*(x-2)*...*1
VAR s:REAL;
n,i:INTEGER;
FUNCTION Giaithua(n:INTEGER):LONGINT;
VAR s,i:LONGINT;
BEGIN
s:=1;
FOR i:=n DOWNTO 1 DO
s:=s*i;
Giaithua:=s;
END;
BEGIN
Write('Nhap n : ');
Readln(n);
s:=0;
FOR i:=0 TO n DO
s:=s+1/giaithua(i);
Write('S= ',s:4:4);
Readln;
END.
Please enable JavaScript to view the
comments powered by Disqus.
comments powered by
Disqus