A community for students.
Here's the question you clicked on:
 0 viewing
anonymous
 5 years ago
Write a program that computes and prints the 1000th prime number,
can somebody help me?
anonymous
 5 years ago
Write a program that computes and prints the 1000th prime number, can somebody help me?

This Question is Closed

anonymous
 5 years ago
Best ResponseYou've already chosen the best response.0Show us what you got so far and we can work from there. It's better to give it a try first rather than just read someone's solution.

anonymous
 5 years ago
Best ResponseYou've already chosen the best response.0x=1 y=2 z=0 while z<10: if y<=x: if x%y==0: print x, x=x+2 y=2 z=z+1 else: y=y+1 else: x=x+2 z=z+1 y=2 i wrote this, try to run this and try to find the errors.thank you

anonymous
 5 years ago
Best ResponseYou've already chosen the best response.0Here is what I want you to do: Just before Print x, I want you to add Print x, y, x%y. You should notice y isn't doing exactly what you want it to do (reaches x instead of x1) When trying to debug a program always add in Print statements. Print the variables and try to see if they match up to what you expect them to be. If not, try to figure out why it happened. If you need some more help with this particular problem let me know.

anonymous
 5 years ago
Best ResponseYou've already chosen the best response.0what pogramming language is this???

anonymous
 5 years ago
Best ResponseYou've already chosen the best response.0kNicola thank you i finally find the solution by using the "for loop' rather than while

anonymous
 5 years ago
Best ResponseYou've already chosen the best response.0No problem. You could have also added an elif clause. elif y < x: y=y+1

anonymous
 5 years ago
Best ResponseYou've already chosen the best response.0Come on now, without giving it any thought at all, you can just cycle through the integers checking whether they are prime or not. Keep track of how many primes you have found so far. When you get to the thousandth one or whatever it is, return it.
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.