A community for students.
Here's the question you clicked on:
 0 viewing
anonymous
 one year ago
This is what I have for ps1a. Am I even close? Also, I keep getting syntax errors for False, why?
for x in range (2, 3000):
is_Prime=True
for y in range (2, 3000):
if x % y == 0:
is_Prime False
anonymous
 one year ago
This is what I have for ps1a. Am I even close? Also, I keep getting syntax errors for False, why? for x in range (2, 3000): is_Prime=True for y in range (2, 3000): if x % y == 0: is_Prime False

This Question is Open

e.mccormick
 one year ago
Best ResponseYou've already chosen the best response.1What is the example assignment? It has been a while since I looked at them...

anonymous
 one year ago
Best ResponseYou've already chosen the best response.0It is Write a program that computes and prints the 1000th prime number. Any help would be greatly appreciated!!

e.mccormick
 one year ago
Best ResponseYou've already chosen the best response.1Basically, a simple prime test is to try and divide a number by other numbers. However, you can make it faster by using a little logic. For example, you can skip all even numbers after 2 because none of them are prime, so the number to be tested can be advanced by 2 each time. Just be sure to adjust your number of primes found up by 1 to account for knowing 2 is not there. Also, you can't divide anything evenly by more than half its value, so you can make the code skip the division of numbers that are greater than half of the number being tested. There are other ways, but if uoi focus on those you can get something that does a resonable number of tests. Each time you get a result, advance the number of primes found. Then the number of primes found reaches 1000, stop testing and print the result. The 1000th prime is 7919. But your program might miss and be a bit over and under, so here are some numbers from a list of 10000 primes. I took the 2 lines that have the 9 before and 10 after that: 7841 7853 7867 7873 7877 7879 7883 7901 7907 7919 7927 7933 7937 7949 7951 7963 7993 8009 8011 8017 It is from this list: https://primes.utm.edu/lists/small/10000.txt

rsmith6559
 one year ago
Best ResponseYou've already chosen the best response.0The last line: is_Prime False should be: is_Prime = False

e.mccormick
 one year ago
Best ResponseYou've already chosen the best response.1oops... I missed that simple one.
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.