[Tutor] Fwd: Help on finding the 1000th prime
Kent Johnson
kent37 at tds.net
Mon Nov 16 22:00:02 CET 2009
---------- Forwarded message ----------
From: Ray Holt <mrholtsr at sbcglobal.net>
Date: Mon, Nov 16, 2009 at 1:55 PM
Subject: RE: [Tutor] Help on finding the 1000th prime
To: Kent Johnson <kent37 at tds.net>
I hit the send button before I was ready. Here is the code that doesn't
work.
primeCount = 0
primeCandidate = 2
While primeCount <= 1000:
isPrime = True
primeCandidate = primeCandidate + 2
for x in range(2, primeCandidate):
if primeCandidate % x == 0:
print primeCandidate, "equals", x, "*", primeCandidate/x
isPrime = False
Print primeCandidate
break
If isPrime:
primeCount = primeCount + 2
Print primeCandidate
-----Original Message-----
From: kent3737 at gmail.com [mailto:kent3737 at gmail.com] On Behalf Of Kent
Johnson
Sent: Monday, November 16, 2009 12:33 PM
To: Ray Holt
Cc: tutor at python.org
Subject: Re: [Tutor] Help on finding the 1000th prime
On Mon, Nov 16, 2009 at 10:56 AM, Ray Holt <mrholtsr at sbcglobal.net> wrote:
> I have posted this on other lists, but have just discovered this one.
> Can someone give me help on writing the code necessary to find the
> 1000th. prime number. I know I will have to use a while loop, but I
> can't seem to get the body of the code to function rightly.
What have you tried so far? What don't you understand?
Kent
More information about the Tutor
mailing list