What is the fastest integer factorization algorithm?

后端 未结 8 1155
灰色年华
灰色年华 2020-11-28 01:49

I\'ve written a program that attempts to find Amicable Pairs. This requires finding the sums of the proper divisors of numbers.

Here is my current sumOfDiviso

相关标签:
8条回答
  • 2020-11-28 02:45

    Pulled directly from my answer to this other question.

    The method will work, but will be slow. "How big are your numbers?" determines the method to use:

    • Less than 2^16 or so: Lookup table.
    • Less than 2^70 or so: Richard Brent's modification of Pollard's rho algorithm.
    • Less than 10^50: Lenstra elliptic curve factorization
    • Less than 10^100: Quadratic Sieve
    • More than 10^100: General Number Field Sieve
    0 讨论(0)
  • 2020-11-28 02:52

    The question in the title (and the last line) seems to have little to do with the actual body of the question. If you're trying to find amicable pairs, or computing the sum of divisors for many numbers, then separately factorising each number (even with the fastest possible algorithm) is absolutely an inefficient way to do it.

    The sum-of-divisors function, σ(n) = (sum of divisors of n), is a multiplicative function: for relatively prime m and n, we have σ(mn) = σ(m)σ(n), so

    σ(p1k1…prkr) = [(p1k1+1-1)/(p1-1)]…[(prkr+1-1)/(pr-1)].

    So you would use any simple sieve (e.g. an augmented version of the Sieve of Eratosthenes) to find the primes up to n, and, in the process, the factorisation of all numbers up to n. (For example, as you do your sieve, store the smallest prime factor of each n. Then you can later factorize any number n by iterating.) This would be faster (overall) than using any separate factorization algorithm several times.

    BTW: several known lists of amicable pairs already exist (see e.g. here and the links at MathWorld) – so are you trying to extend the record, or doing it just for fun?

    0 讨论(0)
提交回复
热议问题