Almost direct translation of related python code.
gcd, "looping construct" python, (FP " " )
let rec gcd = function
| x, 0 -> x
| x, y -> gcd (y, x % y)
coprime , , gcd 1
let coprime = gcd >> (=) 1
, , :
let coprime (x, y) = gcd (x, y) = 1
, ( ), ,
( BigInteger.GreatestCommonDivisor bigint, )
open LanguagePrimitives
let inline gcd (x, y) =
let rec aux (x, y) =
if y = GenericZero
then x
else aux (y, x % y)
aux (x, y)
let inline coprime (x, y) = gcd (x, y) = GenericOne
@Henrik Hansen , ,
let (|LT|EQ|GT|) (x, y) =
if x < y then LT
elif x = y then EQ
else GT
let areCoPrimes x y =
let rec aux (x, y) =
match x, y with
| 0, _ | _, 0 -> false
| LT -> aux (x, y - x)
| EQ -> x = 1
| GT -> aux (x - y, y)
aux (abs x, abs y)