tag:blogger.com,1999:blog-4304505761826299706.post7479211930001885951..comments2022-12-23T08:02:02.554+00:00Comments on WONTFIX: Finding if a number is a primeAndy Tillhttp://www.blogger.com/profile/13022942102319196525noreply@blogger.comBlogger2125tag:blogger.com,1999:blog-4304505761826299706.post-72575032368550527892012-04-06T18:43:50.202+01:002012-04-06T18:43:50.202+01:00Hi Alan
That's a lot better! I will update t...Hi Alan<br /><br />That's a lot better! I will update the post to reflect your proposed changes.<br /><br />I came up with this while I was working on a couple of Project Euler problems so didn't bother to optimise too much as the data sets aren't too big.Andy Tillhttps://www.blogger.com/profile/13022942102319196525noreply@blogger.comtag:blogger.com,1999:blog-4304505761826299706.post-12899179527871712002012-04-05T14:02:15.117+01:002012-04-05T14:02:15.117+01:00Afternoon, Andy.
Afraid I don't like this: I ...Afternoon, Andy.<br /><br />Afraid I don't like this: I think you're checking <i>twice</i> whether the number is even or not, and you test a whole load of unnecessary divisors.<br /><br />Wouldn't <b>for (long i=3; i<=maxCheck; i+=2)</b> be an improvement? But I'm sure we can do better still.Alannoreply@blogger.com