Euler in Groovy 1: sum of numbers
Print the sum of numbers less than 1000 that are divisble by 5 or 3.
The problem is:
Print the sum of numbers less than 1000 that are divisble by 5 or 3.
Already, we're exposed to a few nifty features of Groovy - ranges, and the functional methods on arrays like findAll:
// print the sum of numbers less than 1000 that are divisble by 5 or 3 answer = (1..999).findAll { (it % 3 == 0) || (it % 5 == 0) }.sum() println answer // => 233168