var
a:array[1..1000] of integer;
n, i, j:integer;
flag:boolean;
begin
a[1] := 0;
write('n = '); readln(n);
for i := 2 to trunc(sqrt(n)) do
if n mod i = 0 then
begin
a[1] := i;
n := n div i;
break;
end;
if a[1] = 0 then
begin
writeln(n);
Exit;
end;
i := 1;
while n <> 1 do
begin
flag := false;
for j := a[i] to trunc(sqrt(n)) do
if n mod j = 0 then
begin
a[i + 1] := j;
inc(i);
n := n div j;
flag := true;
break;
end;
if (not flag) and (n <> 1) then
begin
a[i + 1] := n;
inc(i);
break;
end;
end;
//Вторая программа
const
m = 4;
n = 3;
var
a:array[1..m, 1..n] of integer;
i, j, Pr:integer;
begin
randomize;
Pr := 1;
Writeln('Исходный массив');
for i := 1 to m do
begin
for j := 1 to n do
begin
a[i, j] := random(21) - 10;
if a[i, j] > 0 then
Pr := Pr * a[i, j];
write(a[i, j]:4, ' ');
end;
writeln;
end;
writeln;
writeln('Преобразованный массив');
for i := 1 to m do
begin
for j := 1 to n do
if a[i, j] < 0 then
write(Pr:8, ' ')
else
write(a[i, j]:8, ' ');
writeln;
end;
readln;
end.
for j := 1 to i do
write(a[j], ' ');
readln;
end.