Efficently find divisors of numbers up to 20 digits

56 Views Asked by At

I am aware that finding divisors of large numbers is a well known mathematical problem (which is one of the reasons why cryptography works). Most solutions I've stumbled across used prime factorization to speed up the process a bit. However, on numbers bigger then $2^{32}$ all these solutions started to take seconds, minutes and hours.

For some reason this website can find the divisors for numbers up to $20$, digits, thats around $2^{64}$, within milliseconds. The algorithm can be seen by looking at the page source code. Apparently the input number is splitted into a high and a low section. Can somebody tell me the algorithm used here, and why it is so fast?

2

There are 2 best solutions below

0
On

The code here uses a brute force search, with the slight optimization of sieving $\bmod 30$.

2
On

Mathematica factors 20-digit integers in 0.000225 seconds:

Timing[FactorInteger[54605705157543059870]]

{0.000225, 
   {{2, 1}, {5, 1}, {7, 1}, {193, 1}, {811, 1}, {4983813894767, 1}}}

and its speed is due, apparently, to its use of trial division, Pollard p−1, Pollard rho, elliptic curve, and quadratic sieve algorithms. Elliptic Curve Method.