0
0
Hãy luôn nhớ cảm ơn và vote 5*
nếu câu trả lời hữu ích nhé!
Program Tim_uoc;
Uses crt;
Var n,i,S: integer;
Begin
Write('Nhap so n:'); Readln(n);
(*Câu a*)
S:=0;
Write('Cac uoc cua n la:');
For i:=1 t n div 2 do (*N div 2 là chia đến một nửa của n, quá một nửa thì auto không chia hết*)
Begin
If n mod i=0 then write(i);
S:=S+i;
End;
Writeln
Write('Tong cua cac uoc do la:',' ',S);
(*Câu b*)
Write('Cac uoc chan cua so',' ',n,' ','do la:');
S:=0;
For i:=1 to n div 2 do
Begin
If (n mod i =0) and ( i mod 2=0) then Write(i);
S:=S+i;
End;
Writeln
Write('Tong cua cac uoc chan cua so',' ',n,'la:',S);
(*Câu c*)
Write('Cac uoc le cua so',' ',n,' ','do la:');
S:=0;
For i:=1 to n div 2 do
Begin
If (n mod i =0) and ( i mod 2=1) then Write(i);
S:=S+i;
End;
Writeln
Write('Tong cua cac uoc le cua so',' ',n,'la:',S);
(*Câu d*)
Write('Nhung so nho hon hoac bang so',' ',n,' ','ma chia het cho 3 do la:')
For i:=1 to n div 2 do
If (n mod i =0) and ( i mod 3=0) then Write(i);
Writeln
Write('Nhung so nho hon hoac bang so',' ',n,' ','ma chia het cho 5 do la:')
For i:=1 to n div 2 do
If (n mod i =0) and ( i mod 5=0) then Write(i);
Writeln
Write('Nhung so nho hon hoac bang so',' ',n,' ','ma chia het cho 7 do la:')
For i:=1 to n div 2 do
If (n mod i =0) and ( i mod 7=0) then Write(i);
Readln
End.
Hãy giúp mọi người biết câu trả lời này thế nào?
2377
1794
uses crt;
var i,n,tc,tl,ton,tu:longint;
begin
clrscr;
write('n=');readln(n);
for i:=1 to n do
begin
if n mod i=0 then inc(tu,i);
if i mod 2=0 then inc(tc,i) else inc(tl,i);
if (i mod 3=0)or(i mod 5=0)or(i mod 7=0) then inc(ton,i);
end;
writeln('Tong cac uoc tu 1 toi ',n,': ',tu);
writeln('Tong cac so chan tu 1 toi ',n,': ',tc);
writeln('Tong cac so le tu 1 toi ',n,': ',tl);
writeln('Tong cac so chia het cho 3,5,7 tu 1 toi ',n,': ',ton);
readln
end.
//////////////////////////
Một số test cho bạn tham khảo:
Hãy giúp mọi người biết câu trả lời này thế nào?
Bảng tin
202
3305
156
bn vào nhóm mik ko
400
6389
240
...
400
6389
240
Mình đang nghỉ có phép đến hết tháng này mà bạn. Hỏi Trúc là biết -.-