Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem7: What is the 10001st prime number? #11

Open
ghost opened this issue Dec 2, 2014 · 4 comments
Open

Problem7: What is the 10001st prime number? #11

ghost opened this issue Dec 2, 2014 · 4 comments

Comments

@ghost
Copy link

ghost commented Dec 2, 2014

A solution not using a sieve withoutSieve
and a solution using a sieve withSieve.

The one using a sieve is considerably slower.

Luc

@mverbist
Copy link

mverbist commented Dec 3, 2014

I simply brute-forced it, using the given function isPrime(Int)

    Stream.from(2).filter(isPrime)(10000)

I was a bit amazed to see it still performed rather well, given the little effort I put in 😄

samdebacker pushed a commit that referenced this issue Dec 3, 2014
@samdebacker
Copy link
Member

Luc (@LucDupAtGitHub), your sieved version stack overflows on my 1.8
Michel (@mverbist), use Luc's isPrime method to double the speed.

@ghost
Copy link
Author

ghost commented Dec 3, 2014

Sam (@sambdebacker) ... possible ... I sometimes struggled with stack overflows as well ... I replaced natsFrom(2) by Stream.from(2) (cfr code of Michel (@verbist)) ... thx

@ghost
Copy link
Author

ghost commented Dec 3, 2014

Michel (@mverbist) ... good idea to use apply (instead of my (stupid) take and last)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants