Find prime numbers using Scala. Help me to improve
Here’s a functional implementation of the Sieve of Eratosthenes, as presented in Odersky’s “Functional Programming Principles in Scala” Coursera course : // Sieving integral numbers def sieve(s: Stream[Int]): Stream[Int] = { s.head #:: sieve(s.tail.filter(_ % s.head != 0)) } // All primes as a lazy sequence val primes = sieve(Stream.from(2)) // Dumping the first five … Read more