In what ways can we extend euclid's algorithm?
int euclidgcd(int m, int n) { int remainder; /* Make sure m or n are positive integers. If either m or n is equal to zero, return the non-zero integer, or return zero if both m and n are zero. */ if ((m < 0 ? (m = -m) : m) == 0 || (n < 0 ? (n = -n) : n) == 0) { return m == 0 ? n : n == 0 ? m : 0; } /* Make sure m is always greater than or equal to n. */ if (m < n) { int temp; temp = m; m = n; n = temp; } /* Divide m by n and compute the remainder. If the remainder is not equal to zero, do the following in order: 1. Assign m the value of n. 2. Assign n the value of remainder. 3. Repeat the entire process until a remainder of zero is reached. Finally, return n as the greatest common denominator of m and n. */ while ((remainder = m % n)) { m = n; n = remainder; } return n; }
nice very !!!
- so now i have learned on wikipedia - check it please you too - very very interesting and understandably - i think !!!
Thank you very much for this subject !!!
Join our real-time social learning platform and learn together with your friends!