samskivert: Euler 009

12 January 2008

Problem 009:

object Euler9 extends Application {
  for (a <- List.range(1, 1000);
       b <- List.range(a, 1000);
       c <- List.range(b, 1000);
       if (a*a + b*b == c*c && a+b+c == 1000))
    println(a*b*c);
}

Sequence comprehensions coming in handy here.

©1999–2022 Michael Bayne