2
$\begingroup$

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:

FactorInt[x_]:=Module[{},
(Superscript @@@ FactorInteger[x])
]
$\endgroup$
3
  • 1
    $\begingroup$ Analogously to: mathematica.stackexchange.com/q/133083/5478? $\endgroup$
    – Kuba
    May 2, 2018 at 16:47
  • 1
    $\begingroup$ What's Collatz? Is that really needed here? $\endgroup$ May 2, 2018 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, 2018 at 17:01

1 Answer 1

3
$\begingroup$

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

$\endgroup$
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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