Guest User

Untitled

a guest
Jan 23rd, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.31 KB | None | 0 0
  1. let getLPF num =
  2. let rec getLPF l rest =
  3. seq { yield 2L; yield! seq {3L..2L..(rest |> float |> sqrt |> int64)}}
  4. |> Seq.tryFind (fun d -> rest % d = 0L)
  5. |> function
  6. | None -> max l rest
  7. | Some d -> getLPF (max l d) (rest / d)
  8. getLPF 1L num;;
  9.  
  10. getLPF 600851475143L
Add Comment
Please, Sign In to add comment