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
1000th primeHello! i am trying to print a 1000th prime number.
Page 1 of 1
2 Replies - 1030 Views - Last Post: 15 June 2010 - 11:40 AM
Replies To: 1000th prime
#2
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
suppose to do?
And please explain all your increments.
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?
And please explain all your increments.
This post has been edited by cnampheonix: 14 June 2010 - 09:06 PM
#3
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
|
|

New Topic/Question
Reply
MultiQuote








|