2 câu trả lời
program tinh_tong;
uses crt;
var i:integer;
T:real;
begin
clrscr;
T:=0;
for i:=1 to 100 do T:=T+1/i;
write('T= ',T:4:2);
readln;
end.
Cách For..do
Program BTH;
uses crt;
var s:real;
i:byte;
Begin
clrscr;
For i:=1 to 100 do
Begin
s:=s+1/i;
end;
writeln('Tong day so tren la: ',s:4:2);
readln;
end.
Cách While..do
Program BTH;
uses crt;
var s:real;
i,n:byte;
Begin
clrscr;
n:=1;
While n<100 do
Begin
s:=s+1/n;
n:=n+1;
end;
writeln('Tong day so tren la: ',s:4:2);
readln;
end.
Bạn chọn cách nha :)))