Skip to content

Instantly share code, notes, and snippets.

@kingori
Last active December 16, 2015 07:09
Show Gist options
  • Save kingori/5397117 to your computer and use it in GitHub Desktop.
Save kingori/5397117 to your computer and use it in GitHub Desktop.
프로젝트 오일러 1번 풀이
class Euler1 {
/**
* 1 부터 maxVal 미만의 수 중 3 또는 5의 배수의 합
* @param maxVal
* @return
*/
def getMultipleOf3Or5(maxVal: Int) = {
(0 /: (1 until maxVal).filter((arg: Int) => (arg % 3 == 0 || arg % 5 == 0)))(_ + _)
}
}
object Euler1 extends App {
Console.out.println("1 to 10:" + new Euler1().getMultipleOf3Or5(10))
Console.out.println("1 to 1000:" + new Euler1().getMultipleOf3Or5(1000))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment