How do I find the prime factor decomposition of 13980053?

A naive procedure: Try all the numbers between [math2[/math and [math13980053[/math and repeat this recursively with all the found dividers until only prime dividers are left.This is not particularly efficient.

It becomes more efficient if we make two numerical-theoretical considerations:

  1. We only have to check up to [math-frac-n-2-[/math, because the smallest prime divider is [math2[/math.

(Alternatively, we could only check up to [math-sqrt-n-/math and for each divider [matha[/math the equivalent [math-frac-a-[/math), although we can still consider it. would have to take care of the prime factor decomposition of [math-frac-a-[/math), which does not necessarily make it more efficient.)

  • Composite numbers are not interesting for prime factor decomposition.
  • Only the prime dividers are important. Therefore, only the prime numbers up to [math-frac-n-2-[/math, whose density decreases as the number range under consideration increases, must be checked.

    So we can increase the efficiency of the prime factor decomposition of n by first determining the prime numbers up to [math-frac-n-2-[/math and then trying them out.Possible methods for prime determination are the sieve of the erat host (simple) or the sieve of Atkin (slightly more complicated, but more efficient). I use the primerange function from sympy here. Here is not the most efficient, but at least an algorithm from me, which copes quite well with numbers down to the millions.

    ( c) Thomas Willberger-nfrom sympy import sieve-nfrom math import log nn = 13980053 ncandidates = [i for i in sieve.primerange(2, int(n/2+2))'nprimeFactors = dict()'n'n'n for candidate in candidates:'n    if n% candidate==        exponent-n-nif not primeFactors: " empty list, no prime factors"n    print("Prime number!") *****lif len(primeFactors) == 1: prime factor is a single power    key = list(primeFactors.keys())[0'n    primeFactors[key = log(n) [ log(key)'nelse:'n    prod = 1' current product of the prime factors'n    for k in primeFactors.keys(:'n        prod*= k'n'    p = n / prod - number to check n    while    prod < n:n        for factor in primeFactors.keys():n            if p % factor == 0: n                primeFactors[factor += 1 - prime factor exponent n                p /= factor n                prod *= factor                

    The runtime analysis gives the following picture – not all too bad:

    For numbers around 100 million, the above algorithm takes 2-4 seconds.

    This is, of course, a multiple of the time that sympy’s optimized factorint algorithm takes (fraction of a second).

    However, a prime factor decomposition is of course also thick chunks and it is simply not known an efficient method for large prime numbers.Even the fastest known method, the square sieve, has a runtime complexity of [math-mathcal-O-(e-sqrt-ln n-cdot-ln-ln-ln-ln-n-)[math.But this is also a good thing, because encryptions such as RSA rely precisely on this fact by multiplying sufficiently large prime numbers (> 100 digits), from whose product the prime factors can be reconstructed very difficult and inefficiently (and thus a duration of months to years). If there were an efficient method of prime factor decomposition, RSA encryption would be gone.

    And now the output for the number [math13980053[/math:

    Prime number!

    [math13980053[/math is therefore a prime number and cannot be further factoriable.

    Leave a Reply