A community for students.
Here's the question you clicked on:
 0 viewing
anonymous
 4 years ago
Wondering if anyone else has a solution for the 1st problem on the online course. The python program that finds the first 1000 prime numbers. I have a solution but apparently it is not very efficient because it is taking forever to run.
anonymous
 4 years ago
Wondering if anyone else has a solution for the 1st problem on the online course. The python program that finds the first 1000 prime numbers. I have a solution but apparently it is not very efficient because it is taking forever to run.

This Question is Closed

anonymous
 4 years ago
Best ResponseYou've already chosen the best response.0Try this http://mathworld.wolfram.com/SieveofEratosthenes.html

anonymous
 4 years ago
Best ResponseYou've already chosen the best response.0There are a bunch of efficient algorithms out there for generating prime nums, such as the Sieve of Eratosthenes, but for the first 6.00 assignment even simply caching primes you've already found would be very quick

anonymous
 4 years ago
Best ResponseYou've already chosen the best response.0trial division + caching* would be fast enough.... for tiny primes like 7919 even trial division without caching is good enough :D

anonymous
 4 years ago
Best ResponseYou've already chosen the best response.0I programmed it to look for factors whos product was the number I was testing. The test started out true unless it found the two factors. That worked fine for the 1st 100 primes or so, but the 'trues per second' seem to be on the wrong end of an retricemptote approaching 0. lol

anonymous
 4 years ago
Best ResponseYou've already chosen the best response.0only check for factors till sqrt(n)

anonymous
 4 years ago
Best ResponseYou've already chosen the best response.0Great. If you like, you can post the code on a site like http://ideone.com and we can take a look at it.

anonymous
 4 years ago
Best ResponseYou've already chosen the best response.0Maybe. I doubt it's impressive. This is the first program I've ever written.

anonymous
 4 years ago
Best ResponseYou've already chosen the best response.0Took me a long time, too...

anonymous
 4 years ago
Best ResponseYou've already chosen the best response.0That's okay; the first time I tried out 6.00, it took me ages to get used to it.

anonymous
 4 years ago
Best ResponseYou've already chosen the best response.0Turns out I hadn't watched the lecture that spelled this out yet. Light bulbs!!! I redid it and it runs in about 10 seconds now. I learned a lot messing around though.
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.