tính tổng s=1+2+3+...+n

2 câu trả lời

Program viet_chuong_trinh_tong;

uses crt;

var n,i,s:integer;

Begin 

 Clrscr;  

write('nhap so :'); 

 readln(n); 

 S:=0; 

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

 Write('Tong cua 1+2+3+=',S);

readln;

End.

Program TinhTong;
 Uses crt;
Var N,i,S:integer;

Begin
    Clrscr;
    Write('Nhap vao gia tri cua N :'); 

    S:=0;

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

      Writeln('Ket qua la :',S);

      Readln;
End.