[Tutor] Fwd: Help on finding the 1000th prime

Modulok modulok at gmail.com
Mon Nov 16 22:47:37 CET 2009


Also watch things like letter case on stuff like 'Print' and 'While',
they should instead be 'print' and 'while', (all lowercase).

-Modulok-

On 11/16/09, bob gailer <bgailer at gmail.com> wrote:
>
>> Here is the code that doesn't work.
>>
>
> Thanks for posting the code. What "doesn't work" mean?
> error messages?
> unexpected results?
> or what?
>
> There are several problems in your code.
>  - The candidates you are testing. Walk thru the program and list a few
> of them and see if you can determine that problem.
>  - Counting primes as you discover them. Same advice as above.
>  - indentation is screwed up. Please use only spaces - no tabs.
>> 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
>>
>>
>
> --
> Bob Gailer
> Chapel Hill NC
> 919-636-4239
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>


More information about the Tutor mailing list