# August, 2009

Posts
• #### Project Euler Problem #7

Find the 10001st prime let naturals = Seq.unfold ( fun i -> Some(i, i + 1 )) let primes = naturals 2 |> Seq.filter ( fun n -> seq { 2.. int (sqrt (float n)) } |> Seq.forall ( fun x -> n % x <> 0 )) Seq.nth 10000 primes
• #### Project Euler Problem #3

Largest prime factor of 600851475143 : let primeFactors n = let isFactor n d = n % d = 0L let nextFactor n d = seq {d..n} |> Seq.find (isFactor n) (n, 2L, []) |> Seq.unfold ( fun (n, d, a) -> if isFactor n d then Some(d, ((n...
• #### Project Euler Problem #1

Project Euler is pretty darn cool. It’s a bunch of mathematical problems that require programming to solve. I’m having fun doing them in F#. They start very simple but quickly become more difficult. Problem 1 is to find the sum of all the multiples...
• #### Project Euler Problem #5

Smallest number divisible by each of 1 to 20 : First cut (takes almost an hour to execute!): let isFactor n d = n % d = 0 {1..Int32.MaxValue} |> Seq.find ( fun n -> [1..20] |> List.forall (isFactor n)) Second cut (takes a...