The exercise asks me to: enter a quantity x of natural numbers greater than one and show on the screen the decomposition into prime factors of each one, indicate which of them has more prime factors, e.g.:
72 : 2 - 2 - 2 - 3 - 3
50 : 2 - 5 - 5
type
vec=array [0..100] of byte;
var
n,r:byte;
v,m: vec;
procedure leevec(var n : byte; var v: vec);
var
i: byte ;
begin
write('ingre la cantidad de elementos ');
readln(n);
for i:=1 to n do
begin
write(i,': ');
readln(v[i]);
end;
end;
procedure factorprimo(n: byte; var r : byte ;v: vec; var t: vec);
var
i,d:byte;
begin
for i :=1 to n do
r:=1;
while v[i] > 1 do
begin
d:=2;
while (v[i] mod d <> 0) do
d:=d+1; // son los factores primos
t[r]:=d;
r:=r+1; // contador
v[i]:=v[i] div d;
end;
end;
procedure escritura(k:byte; a:vec);
var
i:byte;
begin
for i:=1 to k do
begin
write(a[i],' ');
end;
writeln;
end;
begin
leevec(n,v);
factorprimo(n,r,v,m);
escritura(r-1,v);
end.
This is what I was able to do but as a result I get the prime factors of the last element of the vector and I still couldn't count who has the most FP.