How to combine a list of the prime factors?

As a simple 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 @@ (#[[1]]^#[[2]] & /@ {{2, 1}, {3, 2}, {43, 5}, {26684839, 1}})


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]. May 4, 2015 at 4:21

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]

Table[#1, #2] & @@@ lis // Map[Apply[Sequence]] // Apply[Times]


or

Times @@ (Sequence @@ Table[#1, #2] & @@@ lis)


or

Times @@ (Times @@ Table[#1, #2] & @@@ lis)


or

lis /. {a_, b_} :> a^b // Times @@ # &


Result:

70612139395722186

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


Two slot-free variants of Syed's solution:

Using Splice (new in 12.1)

Times @@ Splice @* Table @@@ list


70612139395722186

Using MapApply (new in 13.1)

Times @@ Flatten @ MapApply[Table] @ list


70612139395722186

• For older versions not featuring MapApply: Times @@ Flatten@Map[Apply[Table]]@list
– Syed
Mar 9 at 0:22