view problem10.py @ 14:49c96972949d default tip

#50 rewrite of solution
author Dominic Cleal <dominic@computerkb.co.uk>
date Mon, 01 Dec 2008 19:11:55 +0000
parents 1ca695e32f66
children
line wrap: on
line source

import math

primes = [ 2 ]

def isPrime(test):
	max = math.floor(math.sqrt(test))
	t = 0
	while t < len(primes) and primes[t] <= max:
		if test % primes[t] == 0:
			return False
		t += 1
	
	return True

i = 3
while i < 2000000:
	if isPrime(i):
		primes.append(i)
	i += 2

print sum(primes)