MathGroup Archive 1995

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: FactorInteger Print Formatting

Alan Powell <POWELLA at> wrote:

>Could anyone suggest a neat way to reformat the output of
>FactorInteger into a more usable print format?

The function fa reformats the output of FactorInteger:

   fa[1] := "1"

   fa[n_Integer] := 
    StringDrop[ StringJoin[ Flatten[
     (ReplacePart[#, Last[#] /. {"1" -> "*", x_String -> "^"<> x <> "*"}, 2] &)  
        /@ Map[ToString, FactorInteger[n], {2}]] ], -1]

For instance:

In[3]:= fa[911]

Out[3]= 911

In[4]:= fa[9122]

Out[4]= 2*4561

In[5]:= fa[640]

Out[5]= 2^7*5

 Levent Kitis           lk3a at    lk3a at
 University of Virginia  Department of Mechanical, Aerospace and Nuclear Engineering  

  • Prev by Date: Re: mixed-font axis labels?
  • Next by Date: Sequential Plotting, and "INKEY$", in Mathematica?
  • Previous by thread: Re: FactorInteger Print Formatting
  • Next by thread: Re: FactorInteger Print Formatting