viet chuong trinh tinh tong N so tu nhien lien tiep. Biêt N la so tu nhien doc nhap vao tu ban phim

2 câu trả lời

uses crt;
var n,i,s:integer;
begin
clrscr;
   write('Nhap N: ');readln(n);
   s:=0;
   for i:=1 to n do s:=s+i;
   writeln(s);
readln
end.

Program baitap;

Uses crt;

Var N,i,S:integer;

Begin

Clrscr;

S:=0;

Write('N='); Readln(N);

For i:=1 to N do S:=S+i;

Writeln('Ket qua:',S);

Readln

End.