Make FactorInteger print its result with CenterDot and Superscript?

I know that if I use

CenterDot @@ (Superscript @@@ FactorInteger[x])


Mathematica will pretty print the output. However, is it possible to tell Mathematica to automatically format the output of FactorInteger with CenterDot and Superscript?

• you can just define your own function: e.g.fi[x_]:=CenterDot @@ (Superscript @@@ FactorInteger[x]) Commented Apr 5, 2014 at 3:59
• I know, but I want to see if it is possible to somehow add onto the built in function using some sort of preprinting directive like "$PrePrint = If[MatrixQ[#],MatrixForm[#],#]&;" Commented Apr 5, 2014 at 4:01 • sorry cannot help in this regard Commented Apr 5, 2014 at 5:05 • I think it's not a good idea to try to do this. Modifying the builtin is definitely a bad idea. It's probably being used by other functions. There are some horror stories on this site about what happens when you modify builtins. About an analogue of the MatrixForm thing, the output is so generic that it's not really possible to detect that it came from FactorInteger. Just define your own function as ubpdqn said! Commented Apr 5, 2014 at 5:06 1 Answer This is the best I can come up quickly. It can be used much in the same way that MatrixForm is. SetAttributes[factorizationForm, HoldFirst]; factorizationForm[expr_] := If[Head[Unevaluated[expr]] === FactorInteger, CenterDot @@ Superscript @@@ expr, expr]  Then FactorInteger[5!] // factorizationForm  but {{2, 3}, {3, 1}, {5, 1}} // factorizationForm  {{2, 3}, {3, 1}, {5, 1}} I think it satisfies the spirit of your question even if it's not what you asked for to the letter. • I tried to combine this along with the matrix form to get:$PrePrint = If[MatrixQ[#], If[Head[Unevaluated[#]] === FactorInteger, CenterDot @@ Superscript @@@ #, MatrixForm[#]],#]&; Commented Apr 5, 2014 at 6:09
• but it does not seem to give the desired result of printing the factorform if it is FactorInteger and otherwise printing it in matrix form. Any idea why? Commented Apr 5, 2014 at 6:09
• Just a couple of ideas. The function you give to $PrePrint doesn't have the HoldFirst attribute and it doesn't return one of the formatted forms, but the evaluated, but unformatted, form of its argument. Commented Apr 5, 2014 at 13:19 • How would you fix it? Do you just do $Preprint = HoldFirst[...]? Commented Apr 5, 2014 at 16:52
• @user2612743. I'm sorry, but my best advice is not to fix it, but to forget about monkeying with $Preprint (which can have strange side-effects unless you know exactly what you are doing) until you have a much better understanding of how Mathematica works. If you don't understand that HoldFirst is an attribute and not a function and what difference that makes, you are not ready to mess with $Preprint. I do recommend this download if you want to learn more. Commented Apr 5, 2014 at 23:41