The following function io[aIn_] produces a list bOut containing ALL the prime factors of an Integer via the standard function FactorInteger[]. My code is:
io[aIn_] :=
(bOut = {};fi = FactorInteger[aIn];Do[bOut~AppendTo~(PadLeft[{}, fi[[i, 2]], fi[[i, 1]]] ), {i, 1, Length[fi]}]; bOut = bOut // Flatten )
I would like to know whether there are other solutions for this "problem"?
My solution does not work with e.g. aIn={12321}; io[aIn] nor with io[{12321}] or io[{12, 21}] and I do not understand all the warnings given by MMA.
I do not like to build a function that treats the integers of an input seperately and combines the results into a single list.
I prefer a solution for io[] with "list in of composite integers" gives " list out of all prime factors".
SetAttributes[f, Listable]; f[n_] := Sequence @@ ConstantArray[#1, #2] & @@@ FactorInteger[n]
$\endgroup$Apply
Join
to my solution to get the former. Or you could just multiply the input numbers together first.. $\endgroup$ConstantArray[#1,# 2]&
I used was redundant. $\endgroup$