score:0

Accepted answer
Welcome to Scala version 2.8.1.final (Java HotSpot(TM) Client VM, Java 1.6.0_24).
Type in expressions to have them evaluated.
Type :help for more information.

scala> lazy val ps: Stream[Int] = 2 #:: ps.map(i => Stream.from(i + 1).find(
     |     j => ps.takeWhile(k => k * k <= j).forall(j % _ > 0)).get)
ps: Stream[Int] = <lazy>

scala> val r = ps.view.takeWhile(_ < 2000000).foldLeft(0L)(_ + _)
r: Long = 142913828922

scala> val r = ps.takeWhile(_ < 2000000).foldLeft(0L)(_ + _)
r: Long = 142913828922

Related Query

More Query from same tag