# Project Euler Problem 26

Project Euler Problem 26 requires familiarity with some math information that can be found at http://mathworld.wolfram.com/FullReptendPrime.html. Translating it into F# gives:

let isFullReptent n = if n % 2 = 0 || n % 5 = 0 then false // n is not relatively prime to 10 else (Seq.initInfinite (fun x -> x+1) |> Seq.filter (fun x -> ((pown 10I x) - 1I) % (bigint (int n)) = 0I) |> Seq.head) + 1 = n // cycle length is n - 1 let problem026 () = [1..999] |> Seq.filter isFullReptent |> Seq.max

Advertisements

Leave a Comment