a)
program Tinh_S;
var
n, S: integer;
i: integer;
begin
write('Nhap gia tri cua n (30 <= n <= 90): ');
readln(n);
S := 0;
if (n >= 30) and (n <= 90) then
begin
for i := 1 to n do
S := S + i;
writeln('Gia tri cua bieu thuc S la: ', S);
end
else
writeln('Gia tri cua n khong hop le!');
readln;
end.
b)
program Tim_n;
var
n, S: integer;
begin
for n := 30 to 90 do
begin
S := 0;
for i := 1 to n do
S := S + i;
if S > 1000 then
begin
writeln('Gia tri cua n la: ', n);
break;
end;
end;
readln;
end.
a)program Tinh_S;
var n,s,i:longint;
begin
s := 0;
write('Nhap n (30 <= n <= 90): ');
readln(n);
for i := 1 to n do
begin
s := s + i;
end;
writeln('Tong S la: ', s);
end.
b) program Tim_N;
var n,s,i: longint;
begin
s := 0;
n := 1;
while s <= 1000 do
begin
s := s + n;
n := n + 1;
end;
writeln('Gia tri n can tim la: ', n-1);
end.