fork download
  1. object Main {
  2. def main(args: Array[String]) {
  3. println(fib(0, 1) takeWhile {_ < 4000000} filter {_ % 2 == 0} sum)
  4. }
  5.  
  6. def fib(x1: Int, x2: Int): Stream[Int] = {
  7. x1 #:: fib(x2, x1 + x2)
  8. }
  9. }
  10.  
Success #stdin #stdout 0.4s 381952KB
stdin
Standard input is empty
stdout
4613732