Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Completed fun prime update #111

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

Closed
kastyan-kg wants to merge 1 commit into completed from completed-fun-prime-update
Closed

Conversation

Copy link
Contributor

@kastyan-kg kastyan-kg commented Oct 11, 2021

prime numbers generation optimization suggestion

@kastyan-kg kastyan-kg changed the base branch from main to completed October 11, 2021 15:55
@@ -25,8 +28,8 @@ private PrimeNumbers() {
* @return an infinite int stream of prime numbers
*/
public static IntStream stream() {
return IntStream.iterate(2, i -> i + 1)
.filter(PrimeNumbers::isPrime);
return Stream.iterate(TWO, BigInteger::nextProbablePrime)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kastyan-kg that's a good option. 👍 However, this exercise is about Stream API, iteration, and ranges. So I would still encourage people to implement isPrime manually. What do you think about that?

Copy link
Contributor Author

@kastyan-kg kastyan-kg Oct 12, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fair enough ;) just was thinking how to do this faster

tboychuk reacted with thumbs up emoji
Copy link
Contributor

Thanks!

@tboychuk tboychuk deleted the completed-fun-prime-update branch October 13, 2021 11:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers

@tboychuk tboychuk tboychuk left review comments

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /