Created
May 13, 2012 14:31
-
-
Save onlyshk/2688691 to your computer and use it in GitHub Desktop.
This file contains 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
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