Created
December 19, 2020 15:49
-
-
Save vietnt/88549315aefd4f19ffb30c5f2c30d21d to your computer and use it in GitHub Desktop.
This file contains 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 isPrime (n: int) = | |
let max = sqrt (float32 n) |> int | |
let rec check m = | |
if m > max then true | |
elif n % m = 0 then false | |
else check (m+1) | |
check 2 | |
let n = 600851475143L // | |
Seq.init (sqrt (float32 n) |> int) (fun i -> i + 2) | |
|> Seq.filter (fun x -> n % int64 x = 0L) | |
|> Seq.filter isPrime | |
|> Seq.last | |
|> printfn "%A" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment