RosettaCodeData/Task/Primality-by-trial-division/F-Sharp/primality-by-trial-division-2.fs
2023-07-01 13:44:08 -04:00

7 lines
227 B
FSharp

let isPrimeI x =
if x < 2I then false else
if x = 2I then true else
if x % 2I = 0I then false else
let rec test n =
if n * n > x then true else
if x % n = 0I then false else test (n + 2I) in test 3I