Created
June 28, 2013 00:35
-
-
Save mbc9news/5881599 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
object Euler_012 extends App { | |
def getPrimeList(orgNum:Int, curNum:Int=1, primeList:List[Int] = List()): List[Int] = { | |
if(orgNum < curNum) return primeList | |
if (orgNum%curNum equals 0) getPrimeList(orgNum, curNum+1, primeList:+curNum) | |
else getPrimeList(orgNum, curNum+1, primeList) | |
} | |
def getAnsByPListNum(tNum:Int, sNum:Int = 2, cSum:Int = 1) : Int = { | |
// println("["+tNum+"]["+getPrimeList(cSum).size+"]["+sNum+"]["+cSum+"]") | |
if(getPrimeList(cSum).size >= tNum) return cSum | |
return getAnsByPListNum(tNum, sNum+1, cSum+sNum) | |
} | |
println(getAnsByPListNum(5)) | |
println(getAnsByPListNum(500)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment