Em hãy sắp xếp chương trình tính tổng N số tự nhiên sau cho phù hợp? Var N, i: integer; Write(‘Nhap so N=’); s:=0; S: Longint; readln(n); For i:=1 to n do Begin Program tinh_tong; S:=s
Giải thích
Lời giải:
Program tinh_tong;
Var N, i: integer;
S: Longint;
Begin
Write(‘Nhap so N=’);
readln(n);
s:=0;
For i:=1 to n do
S:=s+i;
Writeln(‘Tong cua ‘, N, ‘ So tu nhien dau tien s=’, s);
Readln
End.