# how to combine a list of the prime factors

For example, there is a list of prime factors.

{{2, 1}, {3, 2}, {43, 5}, {26684839, 1}}


How to combine them to the number 70612139395722186 using Mathematica?

Times @@ Power @@@ {{2, 1}, {3, 2}, {43, 5}, {26684839, 1}}

Times @@ (#[]^#[] & /@ {{2, 1}, {3, 2}, {43, 5}, {26684839, 1}})


Here is another one

primefactors = {{2, 1}, {3, 2}, {43, 5}, {26684839, 1}};

Fold[Times[#1, Power @@ #2] &, 1, primefactors]


70612139395722186

If the list gets larger enough, you can use ParallelCombine to MapReduce it,

ParallelCombine[Fold[Times[#1, Power @@ #2] &, 1, #]&, primefactors, Times]


For the list of current size, this actually only slows it down. And it can be used with any of the methods show here so far. If the method does it with as a function, f[#]& then:

 ParallelCombine[f[#]&, primefactors, Times]


Also

pf = {{2, 1}, {3, 2}, {43, 5}, {26684839, 1}};

Inner[Power, ## & @@ (pf\[Transpose]), Times]
(* 70612139395722186 *)

• Equivalently, Inner[Power, pf[[All, 1]], pf[[All, 2]], Times]. – J. M.'s ennui May 4 '15 at 4:21