Last active
December 10, 2015 02:19
-
-
Save kozake/4367241 to your computer and use it in GitHub Desktop.
Project Euler Problem 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
/** | |
* 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