Sum Some Primes

Discussion of challenges you have already solved
Post Reply
lifthrasiir
Posts: 8
Joined: Tue Aug 16, 2011 12:35 pm

Sum Some Primes

Post by lifthrasiir »

Thank you Wolfram|Alpha.

Input: sum of Prime[i] for i=49999951..50000000
Output: 49122557320

Of course the "correct" way to solve this problem is finding a fast enough primality testing routine for nine-digit numbers. Plain sieving wouldn't help, so I'd use SPRP-based testing maybe.
magnus
Posts: 20
Joined: Thu Mar 05, 2009 2:29 pm

Post by magnus »

http://primes.utm.edu/lists/small/millions/

is also a valid Hacker-Approach...
Shirosan
Posts: 10
Joined: Sat May 28, 2011 3:40 am

Post by Shirosan »

the guy with wolfram|alpha solution won gold, so I guess silver goes to me:

http://primes.utm.edu/nthprime/index.php#nth
The 49,999,951st prime is 982,450,649
using that, I built a program using php and gmp_php library for the "gmp_nextprime" function, and summed up to 5000000th element
Mad Mike
Posts: 11
Joined: Tue Jun 21, 2011 4:38 pm

Post by Mad Mike »

Neat Wolfram Alpha trick there. I just ended up grabbing a list and abusing Excel' sum functions.
chown -R us ./base
Schnapphahn
Posts: 12
Joined: Sun Oct 26, 2008 4:33 pm

Post by Schnapphahn »

I found and used
http://compoasso.free.fr/primelistweb/p ... ine_en.php

after using https://www.dcode.fr/prime-numbers-search to find out my starting number

The rest was a tiny php summing up.

Am I a hacker now?
Post Reply