Prime Factorization Time Complexity

Click For Summary

Discussion Overview

The discussion revolves around the time complexity of prime factorization algorithms, particularly focusing on a simple algorithm that divides a number by all integers up to its square root. Participants explore the implications of this approach and the classification of time complexity in relation to known algorithms.

Discussion Character

  • Technical explanation
  • Debate/contested

Main Points Raised

  • One participant proposes a simple algorithm for prime factorization that involves dividing a number by all integers up to its square root, suggesting a time complexity of sqrt(n) log(n).
  • Another participant questions the assertion that all known prime factorization algorithms have exponential time complexity, suggesting that an algorithm testing numbers from 1 to N would have a runtime of N log N.
  • A further response clarifies that the complexity of number theoretic algorithms is often described in terms of the size of the representation of the numbers, leading to an exponential classification of the proposed algorithm.
  • It is noted that prime factorization is known to be subexponential, with the number field sieve being mentioned as an example of an L(1/3) algorithm.

Areas of Agreement / Disagreement

Participants express differing views on the classification of time complexity for prime factorization algorithms, with some asserting exponential complexity while others challenge this notion. The discussion remains unresolved regarding the specific complexities of the algorithms discussed.

Contextual Notes

There is a lack of consensus on the definitions and implications of time complexity in the context of prime factorization algorithms, particularly regarding the distinction between the size of numbers and their representations.

gchadwick
Messages
2
Reaction score
0
While I know the time complexity for all known prime factorization algorithms is exponential, I can't seem to get this results for a very simple algorithm.

First assume we're doing this with numbers that are simply the product of two primes (the kind you get when working with RSA and others) a very simple way to do it is to simple divide the number you're trying to factorize, n by every number between 2 and sqrt(n) and seeing which two leave no remainder. If we then say that the division has a time complexity of o(a) where a is the number of digits we can work out the time complexity of factorization by a simple sum, log(n) + log(n) + log(n) + ... + log(n) (where log(n) will be the number of digits in n) the sum will have sqrt(n) terms in giving sqrt(n) log(n) however that is clearly the wrong result, so can anyone tell me where I'm going wrong? I'm sure it's something obvious I just can't see it.
 
Physics news on Phys.org
gchadwick said:
While I know the time complexity for all known prime factorization algorithms is exponential

Are you sure about that? If you're correct then I have the same stumbling block as you, because even an algorithm that tests all numbers 1 to N would only have a run time of NlogN
 
If you're correct then I have the same stumbling block as you, because even an algorithm that tests all numbers 1 to N would only have a run time of NlogN]
That is an exponential algorithm: the complexity of number theoretic algorithms is usually described in terms of the size of the representation of the numbers involved, rather than the size of the numbers themselves.

It takes n = lg N bits to store the number N, and so this algorithm runs in time:

[tex]O(2^{\mathop{\text{lg}} N} \mathop{\text{lg}} N)<br /> = O(2^n n)[/tex]

and is thus exponential.


That said, prime factorization is known to be subexponential: The number field sieve is an L(1/3) algorithm. See Wikipedia's or Mathworld's page for reference.
 
Last edited:
  • Like
Likes   Reactions: WWGD
Ahh that makes sense, I knew it was something obvious, thanks :)
 

Similar threads

  • · Replies 7 ·
Replies
7
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
Replies
9
Views
2K
  • · Replies 13 ·
Replies
13
Views
2K
  • · Replies 0 ·
Replies
0
Views
3K
  • · Replies 13 ·
Replies
13
Views
2K
  • · Replies 10 ·
Replies
10
Views
2K
  • · Replies 16 ·
Replies
16
Views
3K
  • · Replies 12 ·
Replies
12
Views
2K
  • · Replies 4 ·
Replies
4
Views
4K