News for hackers. Stuff that matters.
Re:Code Llama, an AI tool for coding by thewataccount on Thursday August 24, 2023 @04:48PM (#37254355)
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.

Re:Code Llama, an AI tool for coding by nojs on Thursday August 24, 2023 @08:44PM (#37256442)
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