Skip to content

Instantly share code, notes, and snippets.

@daiksy
Created December 19, 2012 00:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daiksy/4333436 to your computer and use it in GitHub Desktop.
Save daiksy/4333436 to your computer and use it in GitHub Desktop.
ご祝儀用に予算内のMax素数を算出するコード
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
}
@daiksy
Copy link
Author

daiksy commented Dec 19, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment