Created
January 9, 2014 05:38
-
-
Save yangwansu/8329870 to your computer and use it in GitHub Desktop.
http://euler.synap.co.kr/prob_detail.php?id=1 10보다 작은 자연수 중에서 3 또는 5의 배수는 3, 5, 6, 9 이고, 이것을 모두 더하면 23입니다. 1000보다 작은 자연수 중에서 3 또는 5의 배수를 모두 더하면 얼마일까요?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def func={start,end -> | |
sum=0; | |
(start..<end).each { | |
if(it%3 == 0 || it%5==0){ | |
sum+=it | |
} | |
} | |
return sum; | |
} | |
print func(1, 1000) | |
def sum=0 | |
(1..<1000).grep{ it%3==0||it%5==0}.each{sum+=it} | |
println sum |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment