diff --git a/src/lib.rs b/src/lib.rs index 862b2d5..3c02722 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -52,4 +52,20 @@ macro_rules! vec2 { temp_vec } }; +} + +fn divisors(integer: u32) -> Result, String> { + // assert!((u32::MAX as f64) < f64::MAX ); + let mut div = vec![]; + for i in 2..(integer as f64).sqrt() as u32 + 1{ + if integer%i == 0{ + div.push(i); + div.push(integer/i); + } + } + if div.is_empty(){ + return Err(format!("{} is prime", integer)); + } + div.sort_unstable(); + Ok(div) } \ No newline at end of file