News for hackers. Stuff that matters.
Re:Can you solve it? The Greplin programming challenge by Natsu on Monday October 11, 2010 @05:47AM (#1779257)
I see that you did brute force primality testing, too. Am I the only one who at least only divided by odd numbers (and two) in their brute-force is_prime function? Technically, you only need to test divide by all primes less than or equal to sqrt(n), after all.

I guess I could have used a faster primality test, but I didn't feel like writing anything that complex. I know there's a website out there that has a test that works for anything under about 10 billion, if memory serves, by using the probabalistic tests and doing a special check for the only exception. Heck, it even gives you the factors for the largest number in its range...

Re:Can you solve it? The Greplin programming challenge by jiaaro on Sunday October 17, 2010 @11:09PM (#1802228)
this code solved the problem in under 1 second.

I would say for code that is executed one time ever, even including the sqrt(n) part is premature optimization (though I did include it)