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.