I'm trying to make a list of rules where every integer is replaced with a string of it's prime factorization:

$$ \left( \begin{array}{c} 1\to \left\{1^1\right\} \\ 2\to \left\{2^1\right\} \\ 3\to \left\{3^1\right\} \\ 4\to \left\{2^2\right\} \\ 5\to \left\{5^1\right\} \\ 6\to \left\{2^1,3^1\right\} \\ 7\to \left\{7^1\right\} \\ 8\to \left\{2^3\right\} \\ 9\to \left\{3^2\right\} \\ 10\to \left\{2^1,5^1\right\} \\ 11\to \left\{11^1\right\} \\ \end{array} \right) $$

However, I don't want the rules to be lists. I want 6 to map to $2^1\cdot 3^1$... and so on. How do I accomplish this?

The factorization code is:

(Superscript @@@ FactorInteger[x])
  • 1
    $\begingroup$ Analogously to: mathematica.stackexchange.com/q/133083/5478? $\endgroup$ – Kuba May 2 '18 at 16:47
  • 1
    $\begingroup$ What's Collatz? Is that really needed here? $\endgroup$ – Henrik Schumacher May 2 '18 at 16:59
  • $\begingroup$ It isn't. I'm just going to ask another question later since this one is answered. $\endgroup$ – Robbie May 2 '18 at 17:01

Something like this?

factorInteger[x_Integer] := Row[Superscript @@@ FactorInteger[x]]
factorInteger /@ Range@10 // Column

enter image description here

To get the results in a list of rules you can use:

With[{numbers = Range@10},
  Thread[Rule[numbers, factorInteger /@ numbers]]
  ] // Column

enter image description here


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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