Skip to content

Instantly share code, notes, and snippets.

@kazua
Created December 4, 2012 10:53
Show Gist options
  • Save kazua/4202635 to your computer and use it in GitHub Desktop.
Save kazua/4202635 to your computer and use it in GitHub Desktop.
Project Euler Problem 23
//http://odz.sakura.ne.jp/projecteuler/index.php?cmd=read&page=Problem%2023
//K.A
object problem23 {
def getNoAbdNum(mn : Int) : Int = {
val an = (0 to mn).map(i => Range(1, i).filter(i % _ == 0).sum).zipWithIndex.filter(j => j._1 > j._2).map(_._2)
val on = an.flatMap(i => an.takeWhile(_ <= mn).map(_ + i))
(1 to mn).diff(on).sum
}
def main(args : Array[String]) {
val mn = 28123
println(getNoAbdNum(mn))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment