03-13-2014, 08:39 AM
Sure, sieve of Eratosthenes works, but if you're looking to calculate a large quantity of primes, it's comparatively slow. Also, small improvement I just figured out: excepting 2, you can do s += 2i to make it slightly more efficient.