Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR C

Greatest common divisor iterative

fn gcd(mut m: i32, mut n: i32) -> i32 {
   while m != 0 {
       let old_m = m;
       m = n % m;
       n = old_m;
   }
   n.abs()
}

fn main() {
    println!("Greatest Common Divisor = {} ",gcd(115, 230));
}
 
PREVIOUS NEXT
Tagged: #Greatest #common #divisor #iterative
ADD COMMENT
Topic
Name
8+3 =