Liblary implements: euc - euclidean algorithm euc_ext - extended euclidean algorithm lcm - least common multiple congruence - congruence soliving function, finding smallest x for solution
Program
rs use euc_lib; fn main() { prinln!("{}", euc_lib::I32::euc_ext(135, 35)); }
OutputNWD = 5, S = -1, T = 4
Simple
Program
rs use euc_lib; fn main() { prinln!("{}", euc_lib::I32::euc(135, 35)); // there is recursive variant too: euc_recursive(135,35) }
Output5
Vector as an argument
Program
rs use euc_lib; fn main() { println!("{:?}", euc_lib::I32::euc_from_vec(vec![21, 14, 56])); }
OutputOk(7)
This version implements Least common multiple calculating method using gcd (Euclidean algorithm)
Program
rs use euc_lib; fn main () { println!("{}", euc_lib::I32::lcm(21, 6)) // there is recursive variant too: lcm_recursive }
Output42
Program
rs use euc_lib; fn main() { println!("{:?}", euc_lib::I32::lcm_from_vec(vec![12,4,8])) }
OutputOk(24)
Program
rs use euc_lib; fn main() { println!("{:?}", euc_lib::I32::congruence(9,21,30)) }
OutputOk(9)
i64 support
To use i64 versions of all functions just use euclib::I64 instead of euclib::I32
Program
rs use euc_lib; fn main() { prinln!("{}", euc_lib::I64::euc_ext(135, 35)); }
OutputNWD = 5, S = -1, T = 4