"On my machine, testing the prime number 27,644,437 took about 1.2 milliseconds with a k value of 50 (far higher than you’ll probably need for your applications.)"<p>I'm sorry, but WHAT?<p>Writing the dumbest implementation of trial-division that I could, in C++ on my laptop, in Debug mode, took 0.0247046 ms to determine definitively if 27,644,437 is prime.<p>My dumbest-possible implementation, in Debug mode, is 48.5 times faster, and doesn't get confused by Carmichael numbers.<p>Move along, folks, nothing to see here.<p>"The trial-division method... gets slow quickly."<p>That may be true, but using the number 27,644,437 as a benchmark will not get you anywhere near that "slow" point.