11-11-2014 04:56 PM - edited 11-11-2014 04:57 PM
For those who attended the Challenge the Champions session on the UK NI Days this Noverber 2014, one of the challenges set was to find the 1000th abundant number in the most efficient way possible.
I've just had a quick play, and this is my solution for anyone who is interested or fancies trying to beat it...
11-13-2014 07:26 AM
Here is a code that is about 4 times efficienter.
11-13-2014 08:09 AM
I like it! Clever way of finding the proper divisors (although beiing picky, your comment about there not being proper divisors > sqrt(n) isn't true.)
I found that using a shift register initialised with a 2 and then a single increment each time was faster than doing ($i++)++;
11-13-2014 08:35 AM
@Richard_Ha wrote:
I like it! Clever way of finding the proper divisors (although beiing picky, your comment about there not being proper divisors > sqrt(n) isn't true.)
Yeah, I just edited your condition, without rethinking the fact. Th enote is untru, but them I merge the factors.
Richard_Ha wrote:
I found that using a shift register initialised with a 2 and then a single increment each time was faster than doing ($i++)++;
I'm not sure about it. I don't say either of them is quicker, jsut wondering. Did you benchmark it?
11-13-2014 08:47 AM
Richard_Ha wrote:
I found that using a shift register initialised with a 2 and then a single increment each time was faster than doing ($i++)++;
I'm not sure about it. I don't say either of them is quicker, jsut wondering. Did you benchmark it?
Yeah, it was only a small gain, but it was in there. I didn't try a i+2 though.