ML

Sử dụng câu lệnh For…do và While…do để viết chương trình
a) s=1+2+3
b) s=2+4+...+2n
c) s=1+2+3+...+n
d) s=1+3+5+…+(2n+1) 
e) s=1+1/2+1/3+...+1/n
f) p=1.2.3...n
h) s=1.2.3
i) s=1+1/2+1/3

 

 

GIÚP VỚI Ạ,CẦN SIU GẤP,HƯA TICK

NT
19 tháng 5 2022 lúc 1:04

b:

uses crt;

var i,n,s:integer;

begin

clrscr;

readln(n);

s:=0;

for i:=1 to n do s:=s+2*i;

writeln(s);

readln;

end.

c: 

uses crt;

var i,n,s:integer;

begin

clrscr;

readln(n);

s:=0;

for i:=1 to n do s:=s+i;

writeln(s);

readln;

end.

d: 

uses crt;

var i,n,s:integer;

begin

clrscr;

readln(n);

s:=0;

for i:=0 to n do s:=s+2*i+1;

writeln(s);

readln;

end.

Bình luận (0)

Các câu hỏi tương tự
TN
Xem chi tiết
LN
Xem chi tiết
TT
Xem chi tiết
LT
Xem chi tiết
LT
Xem chi tiết
TP
Xem chi tiết
KH
Xem chi tiết
LA
Xem chi tiết
LA
Xem chi tiết