samskivert: Euler 002

09 January 2008

Problem 002:

object Euler2 extends Application {
  def fibby (a :Int, b :Int) :Int = {
    val next = a + b;
    return (if (b % 2 == 0) b else 0) + (if (next > 1000000) 0 else fibby(b, next));
  }
  println(fibby(1, 2));
}

©1999–2022 Michael Bayne