Hi I have a question about ps1 I believe I have a good code to test for prime # , how do I write a place to put results and limit results to 1000 ?
Can you be a little bit more specific? what language are you using and what exactly do you want?
with Python I a, trying to find the 1000th prime , my code will produce primes within a range of numbers I specify , I want to be able to only printr the 1000th result .
I think you cannot jump to the 1000th number straightly, what you can do is, create a counter, and each time you find a prime number instead of printing it, increase that counter by 1, and check if that counter is = 1000 then only print the number.
ok that is what I am looking to do , where , and how do I add a counter ?
we cant say that without looking at the code. but the basic idea is that u want an outer loop that iterates everytime u find a prime and goes up to 1000th times
counter = 0 number =1 while(true) { if( number is prime) {counter++} if(counter=1000) { print number break the loop } number++ } here s simple pseudo-code you can create a boolean function for checking if the number is prime.
Hey you know there is a seperate study group for MIT course 6.00 Introduction to Python http://openstudy.com/groups/mit%206.0%20intro%20computer%20science%20(ocw)
Join our real-time social learning platform and learn together with your friends!