A community for students.
Here's the question you clicked on:
 0 viewing
anonymous
 5 years ago
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 ?
anonymous
 5 years ago
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 ?

This Question is Closed

anonymous
 5 years ago
Best ResponseYou've already chosen the best response.0Can you be a little bit more specific? what language are you using and what exactly do you want?

anonymous
 5 years ago
Best ResponseYou've already chosen the best response.0with 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 .

anonymous
 5 years ago
Best ResponseYou've already chosen the best response.0I 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.

anonymous
 5 years ago
Best ResponseYou've already chosen the best response.0ok that is what I am looking to do , where , and how do I add a counter ?

anonymous
 5 years ago
Best ResponseYou've already chosen the best response.0we 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

anonymous
 5 years ago
Best ResponseYou've already chosen the best response.0counter = 0 number =1 while(true) { if( number is prime) {counter++} if(counter=1000) { print number break the loop } number++ } here s simple pseudocode you can create a boolean function for checking if the number is prime.

anonymous
 5 years ago
Best ResponseYou've already chosen the best response.0Hey 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)
Ask your own question
Sign UpFind more explanations on OpenStudy
Your question is ready. Sign up for free to start getting answers.
spraguer
(Moderator)
5
→ View Detailed Profile
is replying to Can someone tell me what button the professor is hitting...
23
 Teamwork 19 Teammate
 Problem Solving 19 Hero
 Engagement 19 Mad Hatter
 You have blocked this person.
 ✔ You're a fan Checking fan status...
Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.