Created
December 4, 2012 10:53
-
-
Save kazua/4202635 to your computer and use it in GitHub Desktop.
Project Euler Problem 23
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%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