Re: 8 bit and FactorInteger ...
- To: mathgroup at smc.vnet.net
- Subject: [mg14527] Re: 8 bit and FactorInteger ...
- From: Paul Abbott <paul at physics.uwa.edu.au>
- Date: Thu, 29 Oct 1998 04:33:25 -0500
- Sender: owner-wri-mathgroup at wolfram.com
Jens-Peer Kuska wrote:
> FactorIntegerForm[faci_]:=
> DisplayForm[Infix[SuperscriptBox[Sequence @@ #] & /@
> faci,"\[Times]"]]
Nice. So things like
FactorInteger[10!]//FactorIntegerForm
work. Two questions:
[1] What is the easiest/best way to get the result back as a number
(i.e. remove the DisplayForm wrappers, etc)?
[2] Is there an easy way to associate FactorForm with FactorInteger
automatically?
Note however that
[1] if the exponent is 1 it is still printed.
[2] your code does not handle GaussianIntegers, e.g.,
FactorInteger[25,GaussianIntegers->True]//FactorIntegerForm
Here is a different approach by Paul Wellin with some additions by Stan
Wagon which handles unit exponents and Complex factors. I expect that
you could extend your code (which makes nice use of Infix) to handle
the Complex case as well.
FactorForm[{}] = 1;
FactorForm[l_] := (
temp = RowBox[{#, "\[CenterDot]"}] & /@
(MapThread[
If[#2 == 1,
If[Head[#1]===Complex,
StringJoin["(", ToString[#1], ")"],
ToString at #1], SuperscriptBox[ToString at #1, #2]]&,
Transpose[l]]);
SequenceForm@@DisplayForm/@
ReplacePart[temp, Drop[temp[[-1,1]],-1],{{-1,1}}])
FactorForm[FactorInteger[12333000, GaussianIntegers->True]]
Note that this is still not perfect: if you use TraditionalForm for
output (as I do) the String conversion changes \[ImaginaryI] into I.
Cheers,
Paul
____________________________________________________________________
Paul Abbott Phone: +61-8-9380-2734
Department of Physics Fax: +61-8-9380-1014
The University of Western Australia Nedlands WA 6907
mailto:paul at physics.uwa.edu.au AUSTRALIA
http://www.physics.uwa.edu.au/~paul
God IS a weakly left-handed dice player
____________________________________________________________________