---------- Forwarded message ---------- From: Ray Holt <mrhol...@sbcglobal.net> Date: Mon, Nov 16, 2009 at 1:55 PM Subject: RE: [Tutor] Help on finding the 1000th prime To: Kent Johnson <ken...@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: kent3...@gmail.com [mailto:kent3...@gmail.com] On Behalf Of Kent Johnson Sent: Monday, November 16, 2009 12:33 PM To: Ray Holt Cc: tutor@python.org Subject: Re: [Tutor] Help on finding the 1000th prime On Mon, Nov 16, 2009 at 10:56 AM, Ray Holt <mrhol...@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 _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor