Rust Min Perimeter Rectangle
fn min_perimeter_rectangle(n: i64) -> i64 {
let mut i = 1i64;
let mut min = i64::MAX;
while i * i < n {
if n % i == 0 {
min = min.min(2 * (i + n / i));
}
i += 1;
}
min
}
This searches factor pairs up to the square root and picks the pair with the smallest perimeter.