MathGroup Archive 1995

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

Search the Archive

Re: FactorInteger Print Formatting

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

Alan Powell <POWELLA at delphi.com> 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 cars.mech.virginia.edu    lk3a at kelvin.seas.virginia.edu
 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