

Hãy luôn nhớ cảm ơn và vote 5*
nếu câu trả lời hữu ích nhé!
Cách tìm ước số:
uses crt;
var i,n:longint;
begin
clrscr;
write('N=');readln(n);
write('Cac uoc: ');
for i:=1 to n do
if n mod i=0 then write(i,' ');
readln
end.
Cách tìm ước số nguyên tố:
uses crt;
var i,n:longint;
function nt(a:longint):boolean;
var i:longint;
begin
i:=2;
while(a>1)and(a mod i<>0)do inc(i);
nt:=i=a;
end;
begin
clrscr;
write('N=');readln(n);
write('Cac uoc so nguyen to: ');
for i:=1 to n do
if (n mod i=0)and(nt(i)) 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?
* Ước số:
uses crt;
var n,i:longint;
begin
clrscr;
readln(n);
for i:=1 to n do
if n mod i=0 then write(i,' '); writeln;
readln
end.
* Ước số nguyên tố:
uses crt;
var n,i:longint;
function nt(a:longint):boolean;
var i:longint;
begin
nt:=true; i:=2;
while (a>1) and (a mod i<>0) do inc(i);
if i<>a then exit(false);
end;
begin
clrscr;
readln(n);
for i:=1 to n do
if (n mod i=0) and (nt(i)) then write(i,' '); writeln;
readln
end.
Hãy giúp mọi người biết câu trả lời này thế nào?
Bảng tin