Skip to content

Instantly share code, notes, and snippets.

@mbc9news
Created June 28, 2013 00:35
Show Gist options
  • Save mbc9news/5881599 to your computer and use it in GitHub Desktop.
Save mbc9news/5881599 to your computer and use it in GitHub Desktop.
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