Created
August 19, 2011 15:09
-
-
Save davidgrenier/1157008 to your computer and use it in GitHub Desktop.
Project Euler 3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let getLPF num = | |
let rec getLPF l rest = | |
seq { yield 2L; yield! seq {3L..2L..(rest |> float |> sqrt |> int64)}} | |
|> Seq.tryFind (fun d -> rest % d = 0L) | |
|> function | |
| None -> max l rest | |
| Some d -> getLPF (max l d) (rest / d) | |
getLPF 1L num;; | |
getLPF 600851475143L |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment