Hãy nhập câu hỏi của bạn vào đây, nếu là tài khoản VIP, bạn sẽ được ưu tiên trả lời.
program Tinh_S;
var i,n:integer;
S:real;
begin
writeln('Nhap so n=') ; readln(n);
i:=1 ; S:=0;
while i<=n do
begin
S:=S+1/n*(n+1); i:=i+1;
end;
writeln('Tong S=',S);
readln
end.
a: uses crt;
var i,n:integer;
s:real;
begin
clrscr;
s:=0;
for i:=1 to 100 do s:=s+1/i;
writeln(s:4:2);
readln;
end.
b:
uses crt;
var i,n:integer;
s:real;
begin
clrscr;
s:=0;
i:=0;
while i<=100 do
begin
inc(i);
s:=s+1/i;
end;
writeln(s:4:2);
readln;
end.
* Sử dụng For ... do
Var i,s:integer;
Begin
For i:=1 to 10 do
s:=s+i;
Write('Tong la ',s);
Readln;
End.
* Sử dụng While ... do
Var i,s:integer;
Begin
i:=1;
While i<=10 do
Begin
s:=s+i;
i:=i+1;
End;
Write('tong la ',s);
Readln;
End.
Var s1,s2,i,j:integer;
Begin
s1:=1;
s2:=0;
i:=2;
j:=4;
While i<=50 do
Begin
s1:=s1+i;
i:=i+2;
End;
While j<=20 do
Begin
s2:=s2+j;
j:=j+4;
End;
s2:=s2+32;
Writeln('Tong day N = ',s1);
Writeln('Tong day M = ',s2);
Readln;
End.
*while..do
Program HOC24;
var i,n: integer;
s: real;
begin
write('Nhap n: '); readln(n);
i:=1;
while i<=n do
begin
s:=s+1/sqr(i);
i:=i+1;
end;
write('S= ',s:6:2);
readln
end.
program tinhtong;
var n,i : integer;
S : real;
begin
write('Nhap n: ');
readln(n);
i:=1;
S:=0;
while i<=n do
begin
S:=S+1/i;
i:=i+1;
end;
writeln('Tong S= ',S);
readln;
end.
program tinh_tong_S;
var
n, i: integer;
S: real;
begin
write('Nhap n: ');
readln(n);
S := 0;
i := 1;
while i <= n do
begin
S := S + 1 / i;
i := i + 1;
end;
writeln('Tong S la: ', S:0:2);
readln;
end.
program TinhTongWhileDo;
var
n, i: integer;
S: real;
begin
write('Nhap so n: ');
readln(n);
S := 0;
i := 1;
while i <= 2*n do
begin
S := S + 1/i;
i := i + 1;
end;
writeln('Tong S=1/1+1/2+1/3+1/4+...+1/2n la: ', S:0:2);
readln;
end.