Looking for something else?

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

## More answers

Looking for something else?

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

- anonymous

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.

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.

Get our expert's

answer on brainly

SEE EXPERT ANSWER

Get your **free** account and access **expert** answers to this

and **thousands** of other questions.

Get your **free** account and access **expert** answers to this and **thousands** of other questions

- anonymous

- katieb

I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!

Get this expert

answer on brainly

SEE EXPERT ANSWER

Get your **free** account and access **expert** answers to this

and **thousands** of other questions

- anonymous

Try this http://mathworld.wolfram.com/SieveofEratosthenes.html

- anonymous

There 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

trial division + caching* would be fast enough.... for tiny primes like 7919 even trial division without caching is good enough :-D

Looking for something else?

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

- anonymous

http://rosettacode.org/wiki/Sieve_of_Eratosthenes#Python

- anonymous

I 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

only check for factors till sqrt(n)

- anonymous

Great. If you like, you can post the code on a site like http://ideone.com and we can take a look at it.

- anonymous

Maybe. I doubt it's impressive. This is the first program I've ever written.

- anonymous

Took me a long time, too...

- anonymous

That's okay; the first time I tried out 6.00, it took me ages to get used to it.

- anonymous

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

Looking for something else?

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