You're viewing a comment by Ian and its responses.
You're viewing a comment by Ian and its responses.
I am being sponsored by Syntress! They bought me an amazing dedicated server to run catonmat on. If you're looking web services, I highly recommend the Syntress guys!
I love to read science books. They make my day and I get ideas for awesome blog posts, such as Busy Beaver, On Functors, Recursive Regular Expressions and many others.
Take a look at my
Amazon wish list, if you're curious about what I have planned reading next, and want to surprise me. :)
If you are interested in advertising on catonmat.net, contact me.
Free tools for coding on Vietstarsoft.com.
Programming homework help.


Jeez, that must have taken a long time. I decided to do it with a sample of about 5 million or so primes and that took a long time.
Also, btw, why do you need to keep the psum? As far as I can see you are outputing the sum up to that point minus the sum up the the point i primes before that. Just keep the sum minus the prime number i primes ago.
sum += $1 - prev[NR-'$i']; prev[NR] = $1; delete prev[NR-'$i']; print sum
also, why do you quit when the sum is greater than the last prime? Wouldn't that skip the prime numbers at the end of the list? In your case it's ok since the answer comes out WAY before the end of the list, but from the looks of it it would miss the solution if it was at the end of the primes.txt file.
Reply To This Comment