Learn
How to break a number into primes.
A short, visual guide to what our fleet computes: why factoring is hard, how the elliptic curve method finds factors, and why it runs so well on thousands of machines at once.
§1Why factor
One number, one set of primes.
Every whole number above 1 is a product of primes in exactly one way. That is the fundamental theorem of arithmetic, and it turns every number into a puzzle with a single solution. The seventh Fermat number resisted until 1970:
2128 + 1 = 59 649 589 127 497 217 × 5 704 689 200 685 129 054 721
Multiplying two primes takes a computer microseconds. Going back, from the product to its primes, can take years. RSA encryption relies on that one-way street, and factoring records measure the state of the art: RSA-250, a 250-digit number, took about 2,700 CPU core-years to factor in 2020.
Most numbers are not as tough as RSA keys. Many of them hide small prime factors that are not on the public record yet. Finding them completes public tables, unblocks other computations and grows FactorDB, the shared database that mathematicians and hobbyists use every day.
Hendrik Lenstra describes the elliptic curve method. It is still the best general tool for finding mid-sized factors.
The largest factor ever found with ECM, by Ryan Propper in 2013.
24096 + 1 still hides a 1,133-digit composite part. Its most recent factor, 54 digits long, came from ECM in 2010.
§2Which method
Search for a factor, or attack the whole number.
Factoring algorithms fall into two families. Some search for a factor, and their cost depends on how big that factor is. Others attack the whole number at once, and their cost depends on its total size.
| Method | Good at | Cost grows with |
|---|---|---|
| Trial division | Factors up to about 12 digits | The size of the factor |
| Pollard's rho | Factors up to about 20 digits | The size of the factor |
| Elliptic curve method | Factors up to 50–60 digits, record 83 | The size of the factor |
| Quadratic sieve | Whole numbers up to about 100 digits | The size of the number |
| Number field sieve | Whole numbers beyond 100 digits, record 250 | The size of the number |
Our numbers have 90 to 110 digits. ECM finds a small factor in seconds, however big the number is. That is why we run ECM first, on many numbers at once, and leave the sieves for numbers that ECM cannot crack.
§3Elliptic curves
Points you can add together.
An elliptic curve is the set of points (x, y) that satisfy y² = x³ + ax + b. Points on it can be added: draw a line through two points, find where it meets the curve a third time and reflect that point across the x-axis.
Adding two points
y² = x³ + ax + bThe same idea, modulo 97
p = 97With this rule the points form a group, so a point can be multiplied by a whole number: k·P is P added to itself k times. Computers get there with a few thousand doublings and additions, even when k has thousands of digits.
§4How ECM works
Make the arithmetic fail, on purpose.
- Pick a random curve and a starting point P, and do all arithmetic modulo N, the number we want to factor. A seed called sigma (σ) picks the curve, so any curve can be replayed.
- Multiply P by a huge number k: the product of every small prime power up to a bound called B1.
- Each step divides modulo N. Secretly the same computation also runs modulo every prime p that divides N. If the curve modulo p has a number of points that divides k, the point reaches infinity there, and one division becomes impossible.
- That impossible division is the prize. Its divisor shares the factor p with N, and a greatest common divisor hands us p. If nothing happens, the curve was unlucky: pick another, because every curve has a fresh, random number of points.
A second stage with a bound B2 gives every curve another chance: it also succeeds when the number of points has one larger prime factor between B1 and B2. The right bounds depend on the size of the factor you hope to find. GMP-ECM's parameter tables recommend:
| Factor size | Stage 1 bound B1 | Factor size | Stage 1 bound B1 |
|---|---|---|---|
| 15 digits | 2,000 | 35 digits | 1,000,000 |
| 20 digits | 11,000 | 40 digits | 3,000,000 |
| 25 digits | 50,000 | 45 digits | 11,000,000 |
| 30 digits | 250,000 | 50 digits | 43,000,000 |
Curious why a particular curve worked? FactorDB's ECM calculator takes a factor p, the parametrization and sigma, and shows the curve's number of points modulo p with its factorization.
§5Try it
Run ECM in your browser.
This is stage 1 of ECM, written with JavaScript BigInt. It tries one random curve after another until a factor falls out. Our providers run GMP-ECM, which is far faster, adds stage 2 and works on numbers five times longer.
§6Why distribute
A lottery that rewards more tickets.
A single curve rarely succeeds. To find a 45-digit factor, GMP-ECM expects thousands of curves at B1 = 11 million, each taking about a minute on one CPU thread. Curves never depend on each other, so the work splits perfectly. Computer scientists call it embarrassingly parallel.
When our fleet finishes, one thread is 0.10% done. Drawn to scale, it would need 13 minutes more.
Golem Network supplies those threads. We rent machines from providers around the world for exactly as long as the search needs them. The same model works for rendering, simulation and machine learning.
§7FactorDB
From a claim to the public record.
A provider's report is a claim, not a result. Our server accepts a factor only after it divides the number exactly. A publisher then reports it to FactorDB with credit to our account, and reads the record back to confirm that everyone can see it.
| Status | Meaning on FactorDB |
|---|---|
| C | Composite, no factors known. This is what we import. |
| CF | Composite, some factors known. Typical after we split a number. |
| FF | Fully factored. Every part is prime. |
| PRP | Probably prime: passed strong tests, not yet proven. |
| P | Proven prime. |
| U | Unknown: not tested yet. |
Our work moves numbers from C to CF, and sometimes all the way to FF.
§8Glossary
Words you will meet here.
Composite
A whole number with a factor other than 1 and itself.
Prime and PRP
A prime has no smaller factors. A PRP, probable prime, passed strong tests but has no proof yet.
Factor and cofactor
If N = p × c, p is the factor we found and c is the cofactor that remains.
C104, P17
Shorthand for a 104-digit composite and a 17-digit prime.
Curve
One ECM attempt: one random elliptic curve, run to the bounds B1 and B2.
Sigma (σ)
The seed that selects a curve, so any curve can be repeated exactly.
B1 and B2
The stage 1 and stage 2 bounds. Larger bounds find larger factors but take longer.
Provider and requestor
A provider rents out its machine on Golem Network. A requestor, like our server, rents it.
vCPU and GLM
A vCPU is one CPU thread; we run one curve on each. GLM is the token Golem providers are paid in.