# Project Euler Problem 40

The solution of Project Euler Problem 40 is straightforward; first I build the fraction’s recording represented as int array of digits, then calculate the result:

open System let concatSeq len ss = new string (ss |> Seq.collect (fun s -> Seq.ofArray <| s.ToString().ToCharArray()) |> Seq.take len |> Seq.toArray) let digits = Seq.initInfinite (fun n -> n) |> concatSeq 1000001 let problem040 () = [1;10;100;1000;10000;100000;1000000] |> List.fold (fun result x -> result * Int32.Parse(string digits.[x])) 1

Advertisements

Leave a Comment