Created
January 20, 2013 06:41
-
-
Save daiksy/4577003 to your computer and use it in GitHub Desktop.
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%2025 | |
// http://projecteuler.net/problem=25 | |
val fib:Stream[BigInt] = BigInt(1) #:: fib.scanLeft(BigInt(1)){(a, b) => a + b } | |
def getDigits = (n: BigInt) => n.toString.size | |
fib.takeWhile(getDigits(_) <= 1000).zipWithIndex.find(t => getDigits(t._1) == 1000).get._2 + 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment