← LibraryModern Factoring Methods ComparedEngineering · MathematicsLesson 383/385← PrevNext →
ArticlePublished 7 Aug 20262 min readBy Kevin Joginfactoring comparisonmethod selectionECMquadratic sieve

Software, Tables and Sources

Modern Factoring Methods Compared

Comparing factoring methods by target size, expected factor size and available hardware, with a practical sequencing recommendation.

Engineering / MathematicsSoftware, Tables and Sources2 min readKV-MATH-0680

Factoring method selection turns on two independent questions: how large the target is, and how large the factors are expected to be. Conflating them is the commonest mistake.

The two axes

Method summary

Factoring methods compared
MethodCost depends onBest for
Trial divisionThe smallest factorFactors below about a million
Pollard rhoThe smallest factorFactors up to about 12 digits
SQUFOFThe targetTargets up to about 18 digits; very small constants
Pollard p-1Smoothness of one less than the factorA cheap opportunistic attempt
ECMThe factor foundFactors from 15 to about 60 digits
MPQS or SIQSThe targetTargets up to about 100 digits
Number field sieveThe targetTargets beyond about 100 digits

Recommended sequencing

Practical factoring sequence

  1. Trial divideTo a modest bound; clears most inputs instantly.
  2. Test for primalityWith Baillie-PSW — never factor a prime.
  3. Check for a perfect powerSee perfect power detection.
  4. Run Pollard rho brieflyCheap; catches small factors.
  5. Run p-1 brieflyCheap and occasionally spectacular.
  6. Run ECM at increasing boundsStrips medium factors; stop when the expected effort exceeds the sieve cost.
  7. Apply a sieveSIQS or the number field sieve by target size.
  8. Recurse on cofactorsEach factor found must itself be tested and factored.

Knowing when to stop with ECM

Hardware

Parallelism by stage
StageParallelism
ECMPerfect; curves are independent
SievingExcellent; intervals are independent
Sieve linear algebraPoor; needs tight coupling
Number field sieve square rootLimited

Special forms

Targets of special algebraic shape admit far better polynomials and are factored well beyond the general record size. Always check whether a target has such a form before treating it as general.

Source. Henri Cohen, A Course in Computational Algebraic Number Theory, Springer GTM 138 — 10. Structural reference unverified: the source file was not available during authoring; chapter and section numbers are taken from the published edition and have not been checked against a physical copy.

Continue learning

Choosing an Algorithm: Decision GuideArticle · MathematicsNEXT LESSON →Implementation Pitfalls and Testing StrategyArticle · MathematicsPublished Tables of Fields and CurvesArticle · MathematicsFurther Reading and Source NotesArticle · Mathematics