Time Complexity: Primality

  • + 0 comments

    But you can pre-calculate prime numbers up to sqrt(n) using seive. Then you can test each number by using just primes, but not all numbers up to sqrt(n), resulting in O(sqrt(n)/log(n)) complexity.