program TinhTongUSL;
var i,n,tong: integer;
begin
writeln('Chuong trinh dem uoc so le cua so N va tinh tong cua chung');
write('Nhap N = ');readln(n);
write('Uoc so le cua N la: ');
tong:=0;
for i:=1 to n do
begin
if n mod i = 0 then
if i mod 2 = 1 then
begin
write(i,', ');
tong:=tong+i;
end;
end;
writeln;
writeln('Tong uoc so le la: ',tong);
readln;
end.
program TinhTongUSL;
var i,n,tong: integer;
begin
writeln('Chuong trinh dem uoc so le cua so N va tinh tong cua chung');
write('Nhap N = ');readln(n);
write('Uoc so le cua N la: ');
tong:=0;
i:=1;
while i<=n do
begin
if n mod i = 0 then
if i mod 2 = 1 then
begin
write(i,', ');
tong:=tong+i;
end;
i:=i+1;
end;
writeln;
writeln('Tong uoc so le la: ',tong);
readln;
end.
Ý kiến bạn đọc
Những tin cũ hơn