Skip to content

Instantly share code, notes, and snippets.

@onlyshk
Created May 13, 2012 14:31
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 onlyshk/2688691 to your computer and use it in GitHub Desktop.
Save onlyshk/2688691 to your computer and use it in GitHub Desktop.
package proj_euler
object Problem7 {
def solve() : Int = {
var n = 2
var i = 1
while (true){
if (is_prime(n) == true)
{
i = i + 1
if (i == 10001)
return n
else
n = n + 1
}
else
n = n + 1
}
return 0
}
def is_prime(n: Int) : Boolean ={
var d = 2
while (d != n - 1){
if (n % d == 0)
return false
else
d = d + 1
}
return true
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment