I am looking for the simplest way to avoid applying Cross to a single argument.

PrimeFactorization[x_] := Cross @@ (Superscript @@@ FactorInteger[x]);
Table[{n, PrimeFactorization[n]}, {n, 200, 250}] // TableForm

enter image description here

  • What about If? – Kuba Aug 16 at 8:00
  • Down vote detected. Thank you! – Friendly Ghost Aug 17 at 12:55
up vote 8 down vote accepted

Since you already use Cross in a way that it's not meant to be used, you can also redefine it and assign a meaning to it when it has only a single argument:

Cross[x_] := x;

A bit less severe: Define your own function.

cross[x__] := Cross[x];
cross[x_] := x;

If it is only for displaying purposes you can use Row:

PrimeFactorization[x_] := Row[#, "\[Cross]"] & @ (Superscript @@@ FactorInteger[x])
  • This solution is not TeXForm friendly. Thank you! – Friendly Ghost Aug 16 at 8:10
  • 9
    @FriendlyGhost there is nothing about TeXForm in your question. – Kuba Aug 16 at 8:12
  • @FriendlyGhost, use BoxForm`$UseTemplateSlotSequenceForRow = False; before using TeXForm on expressions involving Row.(See Incompatibility of Row and TeXForm) – kglr Aug 17 at 8:12

You might define your own function cross, that calls Cross when the number of arguments is larger than 1:

cross=If[Length[{##}]>1, Cross[##], #]&;
  • Thanks. Is there any method to check the number of arguments instead of using your trick with Length[{...}]? – Friendly Ghost Aug 16 at 8:03

An alternative solution without defining new functions:

PrimeFactorization[x_] :=

 Superscript @@@ FactorInteger[x] /. y_ /; Length@y < 0 -> Cross @@ y

For displaying purposes you can also use:

Times @@ Defer@*Power @@@ FactorInteger[10!]

CenterDot @@ Superscript @@@ FactorInteger[10!]

Inactive[Times] @@ Superscript @@@ FactorInteger[10!]

enter image description here

  • (+1) This does not resolve the issue with numbers that are a power if a prime though. – Henrik Schumacher Aug 16 at 16:59

You can use Block in two ways:

  1. temporarily re-define Cross so that Cross[t_] := t:

PrimeFactorization[x_] :=  Block[{Cross}, Cross[t_] := t;
   Cross @@ Superscript @@@ FactorInteger @ x];

PrimeFactorization /@ {211, 222, 223} // TeXForm

$\left\{211^1,2^1\times 3^1\times 37^1,223^1\right\}$

  1. temporarily define Sequence as Cross:

PrimeFactorization2[x_] := Block[{Sequence = Cross},
    ## & @@ Superscript @@@ FactorInteger @ x];

PrimeFactorization2 /@ {211, 222, 223} // TeXForm

$\left\{211^1,2^1\times 3^1\times 37^1,223^1\right\}$

Your Answer


By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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