Skip to content

Instantly share code, notes, and snippets.

@dimdim2
Last active December 17, 2015 23:38
Show Gist options
  • Save dimdim2/5690161 to your computer and use it in GitHub Desktop.
Save dimdim2/5690161 to your computer and use it in GitHub Desktop.
def isPrime(i: Int) = (2 to Math.sqrt(i).toInt).find(i%_ == 0).map(_ => false).getOrElse(true)
//> isPrime: (i: Int)Boolean
def run() {
var (i, count) = (1, 0);
while(count < 10001) {
i += 1
if(isPrime(i)) count += 1
}
println(i)
} //> run: ()Unit
run() //> 104743
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment