Greatest common divisor: Difference between revisions

Line 2,388:
 
=={{header|Rust}}==
===Built-in===
<lang Rust>use std::num::gcd;</lang>
 
===Iterative Euclid algorithm===
<lang Rust>fn gcd(mut m: int, mut n: int) -> int {
Line 2,405 ⟶ 2,408:
{ gcd(n % m, m) }
}</lang>
 
===Tests===
<lang Rust>
println(fmt!("%d",gcd(399,-3999)));
println(fmt!("%d",gcd(0,3999)));
println(fmt!("%d",gcd(13*13,13*29)));
 
3
3999
13</lang>
 
=={{header|Sather}}==
7

edits