diff --git a/src/Algorithms.rs b/src/Algorithms.rs index a87656c..3762c8b 100644 --- a/src/Algorithms.rs +++ b/src/Algorithms.rs @@ -464,3 +464,18 @@ pub fn swapString(strng: String, first: i32, second: i32) -> String{ } return swappedString; } + +//This function returns the gcd of two numbers +pub fn gcd(in1: i32, in2: i32) -> i32{ + let mut num1 = in1; + let mut num2 = in2; + while((num1 != 0) && (num2 != 0)){ + if(num1 > num2){ + num1 %= num2; + } + else{ + num2 %= num1; + } + } + return num1 | num2; +} \ No newline at end of file