# Project Euler Problem 3

Project Euler Problem 3 from the select->filter->aggregate pattern standpoint is still fits perfectly:

first we need to factor the original number, and then just take greatest of its prime factors. No **select** or **filter**, just make a sequence of prime factors and then **aggregate** it by finding the max item in this sequence.

Factoring is implemented by the method that is taught in schools.

let primeFactors n = let rec factorize n f = seq { if n <= f then yield f else match n%f with | 0L -> yield f; yield! factorize (n/f) f | _ -> yield! factorize n (f + 1L) } factorize n 2L let problem003 () = (primeFactors >> Seq.max) 600851475143L

Going forward solutions are to be in the form of a function taking **unit** and returning solution answer as a value of type **‘a** to be invoked by a shared runner . Also all source code can be accessed now at github.com.

Advertisements

## Trackbacks & Pingbacks