Thursday, March 11, 2010

A Groovy solution for Project Euler - Problem 9

// brute force
100.upto 300, { a ->
a.upto 400, { b ->
b.upto 500, { c ->
if (a + b + c == 1000 && a * a + b * b == c * c)
println "$a * $b * $c = " + a * b * c
}
}
}
view raw euler9.groovy hosted with ❤ by GitHub

Answer: 200 * 375 * 425 = 31875000

Here is a link to the problem

No comments:

Post a Comment