list of factors [was: Maple question]
Eric W. Weisstein
eww at wolfram.com
Sat May 1 16:01:57 CEST 2004
On Sat, 1 May 2004, Emeric Deutsch wrote:
> Dear Seqfans,
> I wonder whether this is an appropriate topic.
> Let me formulate my simple question on an example.
> The command ifactor(72) yields 2^3 3^2.
> I would like to get [2,2,2,3,3].
> Any idea? Thanks.
> Emeric
On Sat, 1 May 2004, N. J. A. Sloane wrote:
> > ifactors(72);
> [1, [[2, 3], [3, 2]]]
>
> is as close as you can get - but that's pretty close!
>
> Emeric asked:
> The command ifactor(72) yields 2^3 3^2.
> I would like to get [2,2,2,3,3].
In Mathematica:
Flatten[Table[#1,{#2}]& @@@ FactorInteger[72]]
or
Flatten[Table[#[[1]], {#[[2]]}]& /@ FactorInteger[72]]
or
Flatten[Table[First[#],{Last[#]}]& /@ FactorInteger[72]]
{2,2,2,3,3}
Cheers,
-Eric
More information about the SeqFan
mailing list