MathGroup Archive 1995

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

Search the Archive

Re: FactorInteger Print Formatting

  • To: mathgroup at christensen.cybernetics.net
  • Subject: [mg694] Re: [mg650] FactorInteger Print Formatting
  • From: wmm at chem.wayne.edu (Martin McClain)
  • Date: Mon, 10 Apr 95 10:47:13 EDT

Dear Alan:

Here is a clue.  It is not exactly what you asked for, and it still needs
an automatic way to generate the [[4]] at the end, but I think it is some
progress.

In[23]:=  Trace[FactorInteger[400] /. {a_,b_}->a^b][[4]]

            5   2
Out[23]=  {2 , 4 }

If you try to go beyond this kind of list output to the product form you
asked for, the automatic exponent evaluation machinery takes over and
destroys all progress.  This is closely related to a question I asked
recently, which I suspect has no answer; viz:    How do you prevent 

In[34]:=  Sqrt[8]

Out[34]=  2 Sqrt[2]

I think what we need is an new option, like AnswerForm->pattern, which
would stop evaluation if the desired pattern is created anywhere along the
evaluation chain. 

Has anybody given any thought to this, WRI?

Regards-  Martin

>Could anyone suggest a neat way to reformat the output of
>FactorInteger into a more usable print format?
>
>FactorInteger[n] gives a list of prime factors of the integer n
>in ascending order, together with their exponents viz:
>
>  FactorInteger[900]    produces the list   {{2,2},{3,2},{5,2}}
>
>What I need is a function called say factorform[list] such that:
>
>  Print[ factorform[{{2,2},{3,2},{5,2}}] ]  produces  2^2*3^2*5^2
>
>Ideally exponents equal to 1 would be suppressed so that when
>
>  ff = FactorInteger[30]    produces    {{2,1},{3,1},{5,1}}    then
>
>  Print[factorform[ff]]  would give  2*3*5  instead of  2^1*3^1*5^1  and
>
>  Print[factorform[FactorInteger[2^6*3*5^2*7]]]  would give  2^6*3*5^2*7
>
>A procedural solution is possible, but I was unable to create a simple
>function which would give the desired result.
>
>
>Alan Powell          POWELLA at delphi.com



  • Prev by Date: Re: list of Mma commands with specified properties
  • Next by Date: How to search network for cycles?
  • Previous by thread: FactorInteger Print Formatting
  • Next by thread: Re: FactorInteger Print Formatting