Answers for "iterative greatest common divisor GCD"

C++
0

iterative greatest common divisor GCD

#include <iostream>

using namespace std;

long long gcd(long long m, long long n) {
  while ( m != 0)  {
    long long old_m = m;
    m = n % m;
    n = old_m;
  }
  return abs(n);
}
 
int main() {
    cout << gcd(2672, 5678) << endl;  
}
Posted by: Guest on June-08-2021

Code answers related to "iterative greatest common divisor GCD"

Browse Popular Code Answers by Language