var
n, i: word;
begin
write('Nhap N (N>=2): '); readln(n);
i:=2;
while n>1 do
if n mod i = 0 then
begin
n:=n div i;
write(i,' ');
end
else i:=i+1;
readln;
end.
Nguồn: Gúc
var
n, i: word;
begin
write('Nhap N (N>=2): '); readln(n);
i:=2;
while n>1 do
if n mod i = 0 then
begin
n:=n div i;
write(i,' ');
end
else i:=i+1;
readln;
end.
Nguồn: Gúc
Repeat nè cậu
var t,n:longint;
function kt(x:longint):boolean;
var i:longint;
begin
if x<2 then exit(false);
for i:=2 to trunc(sqrt(x)) do
if x mod i = 0 then exit(false);
exit(true);
end;
begin
clrscr;
readln(n); t:=2;
repeat
if (n mod t=0) and kt(t) then
begin write(t,' '); n:=n div t; end
else inc(t);
until n=1;
readln;
end.
Repeat nè cậu
var t,n:longint;
function kt(x:longint):boolean;
var i:longint;
begin
if x<2 then exit(false);
for i:=2 to trunc(sqrt(x)) do
if x mod i = 0 then exit(false);
exit(true);
end;
begin
clrscr;
readln(n); t:=2;
repeat
if (n mod t=0) and kt(t) then
begin write(t,' '); n:=n div t; end
else inc(t);
until n=1;
readln;
end.