Skip to content

Instantly share code, notes, and snippets.

@kozake
Last active December 10, 2015 02:19
Show Gist options
  • Save kozake/4367241 to your computer and use it in GitHub Desktop.
Save kozake/4367241 to your computer and use it in GitHub Desktop.
Project Euler Problem 5
/**
* Project Euler Problem 5
*/
object P5 {
def from(n:Long)(multiple:Int):Stream[Long] = (n * multiple) #:: from(n + 1)(multiple)
def isAnswer(n:Long):Boolean = !(1 to 20).exists(n % _ != 0)
def answer():Long = {
for (n <- from(1)(20)) {
if (isAnswer(n)) return n
}
return 0
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment