Hi,

I'm stuck with Problem 10 (
http://projecteuler.net/index.php?section=problems&id=10) :-)

A part of my code deals with the calculation of prime numbers. However it is
really slow. Hopefully you have some ideas how to make it faster.

pz = [2]
# only iterate over odd numbers
for i in xrange(3,2000000,2):
  remprod = 1  # product of remainders
  for j in xrange(len(pz)):
    remprod *= (i % pz[j])
    if remprod == 0:  # if a number is divisible wo remainder its not prime
      break
  if remprod > 0:
    pz.append(i)
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to