Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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
Add Comment
Please, Sign In to add comment