question

Abhishek Jain abhishekjain.cooldude.93 at gmail.com
Sun Aug 14 14:36:45 CEST 2011


Hello all,

I wrote a python program to find the 1000th prime no. The program isn't
working as it should be.
Please tell what the error is:

## this is to find the 1000th prime number

number = 3
while number < 10000:
    ###initialize stuff
    counter = 1
    ###initializing list to check primarity
    factor = []
    while counter!=(number/2):
        if number % counter == 0:
            factor = factor + [counter]
        counter = counter + 1
        if len(factor) > 1:
            break
        elif counter == 1000:
            print number,
number+=1



The program is printing all the prime nos. from 1009 to 9973. Please respond
fast and give me the correct code with only simple functions as i am a
beginner to python.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20110814/0643c0be/attachment.html>


More information about the Python-list mailing list