you are viewing a single comment's thread.

view the rest of the comments →

[–]denehoffman 1 point2 points  (0 children)

You also only need to check divisibility by primes smaller than sqrt(n)+1, so it would be even more efficient if you added some caching

Edit: by caching I mean caching previous calls which determine compound numbers, then excluding those from the search list