Hacker News new | past | comments | ask | show | jobs | submit login

I think they're suggesting simply doing +2

+1 is not a good idea since ~half of all numbers are effectively non-prime simply by being even numbers.

You can double the speed by using +2 without using any fancy tricks, just changing a single character.




Well it doesn’t double the speed, since anything with a factor of 2 undergoes only one loop iteration inside is_prime. It basically just saves a function call




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: