| Crates.io | euc_lib |
| lib.rs | euc_lib |
| version | 0.4.0 |
| created_at | 2023-01-20 11:36:28.940887+00 |
| updated_at | 2023-06-17 09:09:34.730685+00 |
| description | Easy to use implementation of extended and normanl Euclidean algorithm |
| homepage | |
| repository | |
| max_upload_size | |
| id | 763307 |
| size | 43,471 |
Program
use euc_lib;
fn main() {
prinln!("{}", euc_lib::I32::euc_ext(135, 35));
}
Output
NWD = 5, S = -1, T = 4
Program
use euc_lib;
fn main() {
prinln!("{}", euc_lib::I32::euc(135, 35)); // there is recursive variant too: euc_recursive(135,35)
}
Output
5
Program
use euc_lib;
fn main() {
println!("{:?}", euc_lib::I32::euc_from_vec(vec![21, 14, 56]));
}
Output
Ok(7)
This version implements Least common multiple calculating method using gcd (Euclidean algorithm)
Program
use euc_lib;
fn main () {
println!("{}", euc_lib::I32::lcm(21, 6)) // there is recursive variant too: lcm_recursive
}
Output
42
Program
use euc_lib;
fn main() {
println!("{:?}", euc_lib::I32::lcm_from_vec(vec![12,4,8]))
}
Output
Ok(24)
Program
use euc_lib;
fn main() {
println!("{:?}", euc_lib::I32::congruence(9,21,30))
}
Output
Ok(9)
To use i64 versions of all functions just use euc_lib::I64 instead of euc_lib::I32
Program
use euc_lib;
fn main() {
prinln!("{}", euc_lib::I64::euc_ext(135, 35));
}
Output
NWD = 5, S = -1, T = 4