Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Project Euler

Name: Anonymous 2010-09-24 23:18

Hey /prog/, I know I'm a little late to the party, but I was wondering how many problems you've solved thus far.
Other discussion regarding Project Euler is also welcome!

Name: Anonymous 2010-09-25 19:30

"""The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17.
Find the sum of all the primes below two million."""

import numpy as np

def sieve(n):
    if n <= 1: return np.array([])
    u = int( np.sqrt(n) )
    plist = np.arange(1, n+1, 2, dtype=int)
    for k in np.arange(1, u):
        if plist[k]:
            plist[ (plist[k] * plist[k])/2 :: plist[k] ] = 0
    plist[0] = 2
    return plist[np.flatnonzero( plist )]

print np.sum( sieve(2000000).tolist() )

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List