Magic squares of doubly even order: Difference between revisions

m
(→‎JS ES6: Simplified diagonals function used in sum checking)
Line 2,197:
 
fn main() {
let n: usize = match env::args().nth(1).and_then(|arg| arg.parse().ok()).expect(
".nth(1)
.and_then(|arg| arg.parse().ok())
.ok_or("Please specify the size of the magic square, as a positive multiple of 4.")
",
);{
Ok(arg) if arg >= 4 && arg % 4 == 0 => arg,
assert!(
nErr(e) =>= 4 && n % 4 == 0panic!(e),
_ => panic!("Argument must be a positive multiple of 4."),
)};
 
let mc = (n * n + 1) * n / 2;
Line 2,228:
i += 1;
}
println!("");
}
}</lang>
Anonymous user