当前位置:网站首页>An elegant program for Euclid‘s algorithm

An elegant program for Euclid‘s algorithm

2022-07-05 03:44:00 Grand mage yunzhongjun

// Euclid's algorithm for greatest common divisor
int euclidAlgorithm (int A, int B){
    
     A=abs(A);
     B=abs(B);
     while (B!=0){
    
          while (A>B) A=A-B;
          B=B-A;
     }
     return A;
}

 Insert picture description here

原网站

版权声明
本文为[Grand mage yunzhongjun]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/186/202207050313025355.html