MathGroup Archive 1995

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

Search the Archive

Re: FactorInteger Print Formatting

  • To: mathgroup at christensen.cybernetics.net
  • Subject: [mg703] Re: [mg650] FactorInteger Print Formatting
  • From: Lou Talman <me at talmanl.mscd.edu>
  • Date: Mon, 10 Apr 95 13:46:25 -0600


How about:

PairOut[{x_, y_}] := "(" <> ToString[x] <> ")" /; y == 1;
PairOut[{x_, y_}] := 

   "(" <> ToString[x] <> "^" <> ToString[y] <> ")" /; y > 1

StringJoin[PairOut /@ FactorInteger[450]]

  (2)(3^2)(5^2)


It's easier to use parentheses than "*"s.

--Lou Talman
  Metropolitan State College of Denver
---------------------------------
Begin forwarded message:

> Date: Thu, 06 Apr 1995 01:56:56 -0500 (EST)
> From: Alan Powell <POWELLA at delphi.com>
> Subject: [mg650] FactorInteger Print Formatting
> To: mathgroup at christensen.cybernetics.net


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: FactorInteger Print Formatting
  • Next by Date: Re: Postscript file printing
  • Previous by thread: Re: FactorInteger Print Formatting
  • Next by thread: Re: FactorInteger Print Formatting