#![allow(dead_code)] #![allow(unused_imports)] use wmath::*; #[test] fn test_number_theory() { let x = 450544905533495325795596640u128; let y = 234836531u128; let z = 38264u128; println!("x is prime: {}", is_prime(x as u128)); println!("y is prime: {}", is_prime(y as u128)); let mut prime_list = find_prime_until(z); // println!("{:?}", prime_list); prime_list.push(1); // check mut let mut factor_without_exp_list = prime_factor_without_exp(x); println!("{:?}", factor_without_exp_list); factor_without_exp_list.push(1); // check mut let mut factor_with_exp_list = prime_factor_with_exp(x); println!("{:?}", factor_with_exp_list); let mut factor_list = factor(x); // println!("{:?}", factor_list); factor_list.push(1); // check mut for factor in factor_list { if x % factor != 0 { println!("Error! TAT"); } } println!("Check Pass! >_<"); factor_with_exp_list.insert(1, 1); // check mut let gcd = greatest_common_divisor(x, z); println!("greatest_common_divisor:{}", gcd); let lcm = leastest_common_multiple(x, z); println!("leastest_common_multiple{}", lcm); let vec = vec![6, 12, 0, 81]; let gcd_in_vector = greatest_common_divisor_in_vector(&vec); println!("greatest_common_divisor_in_vector:{}", gcd_in_vector); let lcm_in_vector = leastest_common_multiple_in_vector(&vec); println!("leastest_common_multiple_in_vector:{}", lcm_in_vector); let vec = vec![6, 12, 81]; let lcm_in_vector = leastest_common_multiple_in_vector(&vec); println!("leastest_common_multiple_in_vector:{}", lcm_in_vector); let (gcd, a, b) = greatest_common_divisor_with_coefficient(x, y); println!("gcd:{}, a:{}, b:{}, a*x+b*y={}", gcd, a, b, a * x as i128 + b * y as i128); let inv = inverse(y, x); println!("inv:{}, (y*inv)%x={}", inv, (y * inv) % x); println!("{:?}", factor(1)); } fn main() {}