Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Given a list of numbers each containing 2 prime factors, I wish to make a list of the products of the logs of each factor. For example, given

L = {4,6,9}, I would like to form P = {Log[2]*Log[2],Log[2]*Log[3],Log[3]*Log[3]}.

FactorInteger seems like a questionable route since it would require some work to distinguish squares from numbers with two distinct prime factors.

Any suggestions? Thank you.

share|improve this question
Warning: Trying to force Mma to display its results in the way you like them is usually difficult and doesn't pay off – Dr. belisarius Jun 13 '13 at 16:47
@belisarius: If you are suggesting that the best way might be a short program then I can accept that. – daniel Jun 13 '13 at 16:56
I do not see how this can be done without, in effect, factoring the number. – Daniel Lichtblau Jun 13 '13 at 18:24
@DanielLichtblau: No, that has to be done. – daniel Jun 14 '13 at 0:48

You could try a couple of rules, but the heads of the elements in the output list will mix Times and HoldForm...

Map[FactorInteger,{4,6,9,15,25,33,49,51}] /.
share|improve this answer
Alternatively: {4, 6, 9, 15, 25, 33, 49, 51} /. n_Integer /; PrimeOmega[n] == 2 :> Times @@ Log[Flatten[ConstantArray @@@ FactorInteger[n]]] – J. M. Jun 13 '13 at 18:23
Actually this was better than what I had anticipated, thanks. – daniel Jun 13 '13 at 23:52

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.