Geeks With Blogs
Buhay Programmer Dont byte more than you can chew January 2008 Entries
F# Solution : Project Euler Problem 25
The Problem : What is the first term in the Fibonacci sequence to contain 1000 digits? The sweet solution : #light open System let fib = (1I,1I) |> Seq.unfold ( fun (sqEntry, acc) -> Some (acc, (acc, acc + sqEntry)) ) |> Seq.filter (fun x -> x.ToString().Length = 1000) |> Seq.nth 0 print_any fib Console.ReadLine() ahh... such power and elegance.... Let me breakdown the solution (1I,1I) |> Seq.unfold ( fun (sqEntry, acc) -> Some (acc, (acc, acc + sqEntry)) ) This line creates ......

Posted On Friday, January 18, 2008 5:24 PM

Copyright © Erik Araojo | Powered by: GeeksWithBlogs.net