MathGroup Archive 2000

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

Search the Archive

Re: ExponentFunction


Stan Wagon (Mathematica in Action, Telos 1997) defined a nice function which
outputs the results of FactorInteger in prime factor-exponent form.
Modifying it slightly to include the dot separator gives a pretty output:

displayFactorInteger::usage =
    "displayFactorInteger[f] displays the list f, of the form returned by \
FactorInteger, as a list of individual prime factors with superscripted \
exponents separated by a dot." ;

displayFactorInteger[l_] := SequenceForm @@
( (DisplayForm[RowBox[{#1, "."}]] & ) /@
(MapThread[
If[#2 == 1,
If[Head[#1] === Complex,
StringJoin["(", ToString[#1], ")"],
ToString at #1], SuperscriptBox[ToString at #1, #2]] &,
Transpose[l]]));


In[2]:=FactorInteger[100!] // displayFactorInteger


Atul

BobHanlon at aol.com wrote in message <8l3fqv$l03 at smc.vnet.net>...
>
>In a message dated 7/18/2000 2:03:01 AM, greg at mira.net writes:
>
>>I just thought of another quick question I'd like to throw in while I'm
>>in the newsreader: I'm having trouble composing an elegant functional way
>>of
>>converting the results of FactorInteger into a form where all the factors
>>(with multiples) are strung together dot separated (example
>>2.2.2.3.3.43.1181). Any ideas?
>
>x = 2*2*2*3*3*43*1181;
>
>Dot @@ Flatten[Table[#[[1]], {#[[2]]}] & /@ FactorInteger[x]]
>
>2 . 2 . 2 . 3 . 3 . 43 . 1181
>
>Times @@ % == x
>
>True
>
>
>Bob Hanlon
>





  • Prev by Date: Why Does AbsoluteOptions Not Tell about all Automatic?
  • Next by Date: Mathematica 3.0: reliability close to LogZero?
  • Previous by thread: Re: ExponentFunction
  • Next by thread: Re: ExponentFunction