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):
for y in range (2, 3000):
if x % y == 0:
MIT 6.00 Intro Computer Science (OCW)
Stacey Warren - Expert brainly.com
Hey! We 've verified this expert answer for you, click below to unlock the details :)
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga.
Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus.
Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
What is the example assignment? It has been a while since I looked at them...
It is Write a program that computes and prints the 1000th prime number. Any help would be greatly appreciated!!
Basically, 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: