pub trait EGCDwhere Self: Sized,{ fn egcd(a: &Self, b: &Self) -> (Self, Self, Self); }
Extended GCD algorithm
For given a, b calculates gcd(a,b), p, q such as gcd(a,b) = a*p + b*q
gcd(a,b) = a*p + b*q
let (a, b) = (BigInt::from(10), BigInt::from(15)); let (s, p, q) = BigInt::egcd(&a, &b); assert_eq!(&s, &BigInt::from(5)); assert_eq!(s, a*p + b*q);