You're viewing a comment by Ian and its responses.

June 07, 2008, 14:03

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

(why do I need your e-mail?)

(Your twitter name, if you have one. (I'm @pkrumins, btw.))

Type first 3 letters of your name: (just to make sure you're a human)

Please preview the comment before submitting to make sure it's OK.