[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

efficient way of generating primes up to n

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 11
Thread images: 2

File: sieve.png (81KB, 885x719px) Image search: [Google]
sieve.png
81KB, 885x719px
Whats the most efficient way to compute every prime from 0 to n without errors?

is using the sieve of Eratosthenes a good choice? I just feel like there could be a more efficient way to do this.
>>
>>8918121
>is using the sieve of Eratosthenes a good choice?

Yes. There are other sieves that might be more efficient in certain situations.
>>
>>8918123
where would one learn about these non-Eratosthenian sieves
>>
>>8918121
>Gnu nano
>python

>>>/g/tfo
>>
File: screenshot.png (60KB, 1354x625px) Image search: [Google]
screenshot.png
60KB, 1354x625px
>>8918136
I had to do this in python or java, i didnt have a choice.
>>
>>8918121
>what ist the modulo operator
>>
>>8918141
>Doing one of Google's super secrit interviews

Why the fuck does that company act like it's a fucking clubhouse run by 10 year olds?
>>
>>8918121
Just open up wikipedia and look at the definition of prime numbers. Then use modulo like >>8918153
said
>>
>>8918153
thats likely the slowest way to do this sort of problem
>>
>>8918128
https://en.wikipedia.org/wiki/Generating_primes

It mentions sieve of Atkin, and wheel sieves.
>>
>>8918174
damn. good link. Sieve of Atkin is pretty sick actually
>https://en.wikipedia.org/wiki/Sieve_of_Atkin
Thread posts: 11
Thread images: 2


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.