Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1995

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

Search the Archive

Re: FactorInteger Print Formatting

  • To: mathgroup at
  • Subject: [mg748] Re: FactorInteger Print Formatting
  • From: Count Dracula <lk3a at>
  • Date: Wed, 12 Apr 1995 17:06:42 GMT
  • Organization: University of Virginia

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