B= 1/1+1/2+1/3+....+1/n D= 1/2+1/4+1/6+...+1/n F= 1+1/3+1/5+1/7+...+1/n
2 câu trả lời
program oken;
uses crt;
var i,n:integer;
b:real;
begin
write('nhap n: '); readln(n);
b:=1;
for i:=1 to n do
b:=b+(i/(i+1));
writeln('B=',b:0:3);
readln;
end.
câu 2:
program oken;
uses crt;
var i,n:integer;
d:real;
begin
write('nhap n: '); readln(n);
d:=1;
for i:=1 to n do
if i mod 2 = 0 then
d:=d+(1/i);
writeln('D=',d:0:3);
readln;
end.
câu 3:
Program oken;
uses crt;
var i,n:intger;
f:real;
Begin
clrscr;
write('Nhap n: ');readln(n);
For i:=1 to n do
Begin
If i mod 2=1 then f:=f+1/i;
end;
writeln('F=',f:0:3);
readln;
end.
b/
Program BTH;
uses crt;
var i,n:longint;
s:real;
Begin
clrscr;
write('Nhap n: ');readln(n);
For i:=1 to n do s:=s+1/i;
writeln('Tong day so tren la: ',s:4:2);
readln;
end.
d/
Program BTH;
uses crt;
var i,n:longint;
s:real;
Begin
clrscr;
write('Nhap n: ');readln(n);
For i:=1 to n do
Begin
If i mod 2=0 then s:=s+1/i;
end;
writeln('Tong day so tren la: ',s:4:2);
readln;
end.
f/
Program BTH;
uses crt;
var i,n:longint;
s:real;
Begin
clrscr;
write('Nhap n: ');readln(n);
For i:=1 to n do
Begin
If i mod 2=1 then s:=s+1/i;
end;
writeln('Tong day so tren la: ',s:4:2);
readln;
end.