Created
October 24, 2016 22:44
-
-
Save Sciss/965088d063f37e3c0789c41fb6a7c472 to your computer and use it in GitHub Desktop.
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
| // quick hack -- no idea if this is elegant or fast | |
| implicit class NextPrime(n: Int) { | |
| def nextPrime: Int = | |
| Iterator.from(n).filter(_.isPrime).next | |
| def isPrime: Boolean = n > 1 && (2 until n).forall(m => n % m != 0) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment