A community for students.

Here's the question you clicked on:

55 members online
  • 0 replying
  • 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 ?

  • This Question is Closed
  1. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Can you be a little bit more specific? what language are you using and what exactly do you want?

  2. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    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 .

  3. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    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.

  4. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    ok that is what I am looking to do , where , and how do I add a counter ?

  5. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    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

  6. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    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.

  7. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    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)

  8. Not the answer you are looking for?
    Search for more explanations.

    • Attachments:

Ask your own question

Sign Up
Find more explanations on OpenStudy
Privacy Policy

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
  • 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.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.