Created
November 17, 2012 09:03
-
-
Save kazua/4094396 to your computer and use it in GitHub Desktop.
Project Euler Problem 07
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
| //http://odz.sakura.ne.jp/projecteuler/index.php?cmd=read&page=Problem%207 | |
| //K.A | |
| import scala.math._ | |
| object problem07 { | |
| def getPrime(cnt : Int) : Int = { | |
| val pr = 2 #:: Stream.from(3) | |
| pr.filter(i=> pr.takeWhile(j=> pow(j, 2) <= i).forall(i % _ > 0))(cnt - 1) | |
| } | |
| def main(args : Array[String]) { | |
| val cnt = 10001 | |
| val gpc = getPrime _ | |
| println(gpc(cnt)) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment