Created
December 19, 2012 00:38
-
-
Save daiksy/4333436 to your computer and use it in GitHub Desktop.
ご祝儀用に予算内のMax素数を算出するコード
This file contains hidden or 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 maxPrime(n: Int) = { | |
def isPrime(n: Int) = Iterator.from(2).takeWhile(p => p * p <= n).forall(p => n % p != 0) | |
(1 to n).filter(isPrime).max | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
元ネタはこちら
https://twitter.com/ayato_p/status/281193170040152065