We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
For completeness, I implemented a Sieve of Erathosthenes for the prime check. I also treated all negative numbers as not prime, although that can apparently be argued...
you code is nice and simple and easy for beginners to understand those who are about to learn lambdas....thanks!!
next step if you can migrate this code into something called as stream pipelining
13
2 1
2 2
2 3
2 4
2 5
2 6
2 7
2 8
2 9
2 10
2 11
2 12
2 13
PRIME
PRIME
PRIME
COMPOSITE
PRIME
COMPOSITE
PRIME
COMPOSITE
PRIME
COMPOSITE
PRIME
COMPOSITE
PRIME
Not sure if the isPrime() method works. The loop seems to exit during the first iteration.
Java Lambda Expressions
You are viewing a single comment's thread. Return to all comments →
Its a bit long but easy to understand...
For completeness, I implemented a Sieve of Erathosthenes for the prime check. I also treated all negative numbers as not prime, although that can apparently be argued...
you code is nice and simple and easy for beginners to understand those who are about to learn lambdas....thanks!! next step if you can migrate this code into something called as stream pipelining
People try too hard to write complex one line solutions to seem smart, but actual clean code looks more like this, it is easy to read and understand.
I never understood how lambda expressions worked until now, thanks a lot.
13 2 1 2 2 2 3 2 4 2 5 2 6 2 7 2 8 2 9 2 10 2 11 2 12 2 13 PRIME PRIME PRIME COMPOSITE PRIME COMPOSITE PRIME COMPOSITE PRIME COMPOSITE PRIME COMPOSITE PRIME
Not sure if the isPrime() method works. The loop seems to exit during the first iteration.
ur isprime() methode seems to be wrong..!! there is no need of else block..
why no comments?