Skip to content

Instantly share code, notes, and snippets.

@daiksy
Created January 20, 2013 06:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daiksy/4577003 to your computer and use it in GitHub Desktop.
Save daiksy/4577003 to your computer and use it in GitHub Desktop.
// 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