Here's my attempt:

#!/usr/bin/env python

import math

for x in range(3,1000,2):

    isPrime = True

    for y in range(3,(math.sqrt(x) + 1)):
        if x % y == 0:
            isPrime = False
            break

    if isPrime:
        print "%d is prime." % x

Notes: This doesn't bother with even numbers at all, and uses the
square root function of "math."

Any improvements anyone?
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to