FrankKair / polyglot-euler

📜 Project Euler solutions in various programming languages
MIT License
74 stars 14 forks source link

Scala 003 #36

Closed lucaspbordignon closed 6 years ago

lucaspbordignon commented 6 years ago

How the solution works

To verify if a given number is prime, simply check from 2..sqrt(n) for odd numbers, as there is no need to check more than that.

Finds the prime numbers that compose the given number an take the last of inserted on the set.

Note: When calling .last on a set in scala, it takes the last inserted element

Performance

Benchmark

Real time: 3.335 s
User time: 5.225 s
Sys. time: 0.342 s
CPU share: 166.93 %
Exit code: 0

(You can alternatively $ time your program).

FrankKair commented 6 years ago

Can you git rebase master and git push -f to sync with the master branch?