Prime Factorization

Author

Eric W. Weisstein
August 25, 2004

This notebook downloaded from http://mathworld.wolfram.com/notebooks/PrimeNumbers/PrimeFactorization.nb.

For more information, see Eric's MathWorld entry http://mathworld.wolfram.com/PrimeFactorization.html.

©2005 Wolfram Research, Inc. except for portions noted otherwise

Additional Authors

FactorForm by Lou D'Andria
August 25, 2004

Code

SetAttributes[FactorForm,Listable];

FactorForm[n_?NumberQ,opts___]:=Times@@(HoldForm[Power[##]]&@@@FactorInteger[n,opts])

Notation

FactorForm[Range[20]]

Timing

Table[FactorInteger[n],{n,10^4}];//Timing

Table[FactorInteger[n],{n,10^5}];//Timing

Table[FactorInteger[n],{n,10^6}];//Timing

Formatted Table

DisplayForm[GridBox[
Flatten/@Transpose@Partition[Table[{n,FactorInteger[n]/.List[p_Integer,1]:>HoldForm[p]/.
List[p_Integer,k_Integer]:>HoldForm[p^k]/.List[x__]:>Times@x/.{}->1},
{n,50}],10],
GridFrame->True,RowLines->True,ColumnLines->True]]

Integers into Gaussian Integers

Table[{n,FactorInteger[n,GaussianIntegers->True]},{n,20}]//ColumnForm

Primes into Gaussian Integers

t=Table[Prime[n],{n,10000}];
mod3=Select[t,Mod[#,4]==1&];
fac=Select[t,Length[FactorInteger[#,GaussianIntegers->True]]==3&];

fac==mod3

Union[First/@(FactorInteger[#,GaussianIntegers->True]&/@mod3)]

Rest[FactorInteger[#,GaussianIntegers->True]]&/@mod3

fac

Solve[(r+i I)x==i+r I,x]

FullSimplify[%]

((Expand[(i+I r)(-I i+r)])/(Expand[(I i+r)(-I i+r)]))

Select[Table[Prime[n],{n,100}],Mod[#,4]==3&]

FactorInteger[#,GaussianIntegers->True]&/@%