News for hackers. Stuff that matters.
Re:Code Llama, an AI tool for coding by Our_Benefactors on Thursday August 24, 2023 @04:46PM (#37254324)
https://stackoverflow.com/a/54544012/1336678

Common approach is to use square roots, this reduces the runtime. Recommend checking out project euler if you like solving hard math-code-o(n)-puzzles.

Re:Code Llama, an AI tool for coding by noduerme on Thursday August 24, 2023 @05:27PM (#37254762)
I didn't want to cheat by looking on S.O. but thanks ;)

Yes it makes sense (in the GPT code) that you'd only go up to i * i ... although looking at pythonic while: statements is just gross to me in this context, it would feel a lot more readable to say, e.g. in PHP:

for ($i=2;$i<sqrt($n);) { $i+=($i==2 ? 1 : 2); //although the first one should just be outside the loop }