Time Complexity: Primality

  • + 1 comment

    I had the same experience with sieve and BitArray in C#.

    Making the sieve in the first place is just too expensive for this input. If we had many more primes to check, then pre-calculating the sieve and then just quickly referencing it when checking for primality would have been much faster than brute-checking each number individually. But in this case, there are simply too few numbers to check to justify the price of the sieve construction.