Created
April 17, 2013 13:25
-
-
Save mbc9news/5404272 to your computer and use it in GitHub Desktop.
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
//http://euler.synap.co.kr/prob_detail.php?id=1 | |
//10보다 작은 자연수 중에서 3 또는 5의 배수는 3, 5, 6, 9 이고, 이것을 모두 더하면 23입니다. | |
//1000보다 작은 자연수 중에서 3 또는 5의 배수를 모두 더하면 얼마일까요? | |
class Euler_001 { | |
def multiple3or5(x:Int){ | |
var total = 0 | |
for (num <- Range(1, x) | |
if(num%3==0 || num%5==0)){ | |
total += num | |
} | |
println("["+x+"]["+total+"]") | |
} | |
} | |
object Euler_001 extends App { | |
new Euler_001().multiple3or5(10) | |
new Euler_001().multiple3or5(1000) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment