Page 1 of 1

Reputation:

# 1000th prime

Posted 14 June 2010 - 08:27 PM

Its a beginner's level program so i cant use functions or strings or any high level stuff just basic iterations and condition statements! I tried a lot but there is no use. Please check and verify and send the correct program. THANKING YOU.

n=raw_input('Enter the value: ')
n=int(n)
a=2
b=1
d=0
while(d!=n):

while(b<=a):
if (a%b==0):
c=c+1
b=b+1
if (c==2):
d=d+1
if(d==n):
print(a)
b=1
a=a+1

Is This A Good Question/Topic? 0

## Replies To: 1000th prime

### #2 cnampheonix

Reputation: 1
• Posts: 63
• Joined: 03-December 09

## Re: 1000th prime

Posted 14 June 2010 - 09:05 PM

Please try to use the "[c o d e] [/c o d e]" it really helps us to read your code better.
It would also help to label your variables with better meaning.
I understand that you are trying to find primes.
There is another post up with the same topic if you want to look that over. In any case, I'm not following your thought process with your code.
Could you explain what your trying to do?

What is your
```while(d!=n):

```

suppose to do?

This post has been edited by cnampheonix: 14 June 2010 - 09:06 PM

### #3 SpeedisaVirus

• Baller

Reputation: 114
• Posts: 855
• Joined: 06-October 08

## Re: 1000th prime

Posted 15 June 2010 - 11:40 AM

It will also help to explain what is wrong with the code. From what I can see you are taking a naive approach. If you want to impress your instructor a little bit you might want to try and implement a sieve instead.

Page 1 of 1

 .related ul { list-style-type: circle; font-size: 12px; font-weight: bold; } .related li { margin-bottom: 5px; background-position: left 7px !important; margin-left: -35px; } .related h2 { font-size: 18px; font-weight: bold; } .related a { color: blue; }