Return to Snippet

Revision: 10233
at December 13, 2008 10:26 by theobriscoe


Initial Code
def numberList = []
	for (i in 1..999) {
		if (i.mod(3) == 0){
			numberList.add(i)
		}
		else if (i.mod(5) == 0){
			numberList.add(i)
		}
	}		
println "totoal = " + numberList.sum()

Initial URL
theobriscoe.com/blog

Initial Description
Add all the natural numbers below one thousand that are multiples of 3 or 5.

If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9.

The sum of these multiples is 23.
http://projecteuler.net/index.php?section=problems&id=1

Initial Title
Project Euler: Add all the natural numbers below one thousand that are multiples of 3 or 5.

Initial Tags


Initial Language
Groovy