Return to Snippet

Revision: 27074
at May 21, 2010 10:39 by chroto


Initial Code
#!/usr/bin/python

print "\nProject Euler - Problem 10"
print "Find the sum of all primes below two million."

# Primes are divisible only by themselves
n = 2000000
nums = range(0,n)
sqrt = int(n ** 0.5)
a = []
a.append(1)
for x in range(1,n+1):
    a.append(1)

for m in range(2,sqrt):
    if a[m] == 1:
        k = m*m
        while k <= n:
            a[k] = 0
            k += m

x= sum([i*j for i,j in zip(a,nums)])

print x

Initial URL

                                

Initial Description

                                

Initial Title
Project Euler - Problem 10

Initial Tags

                                

Initial Language
Python