Created
August 3, 2019 14:11
-
-
Save Sicalxy/7ca35eb7ea9f6bd81e47196ce7944502 to your computer and use it in GitHub Desktop.
Extended Euclidean Algorithm 扩展欧几里得算法
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int gcdEx(int a, int b, int *x, int *y) | |
{ | |
if(0 == b) | |
{ | |
*x = 1; | |
*y = 0; | |
return a; | |
} | |
else | |
{ | |
int r = gcdEx(b, a % b, x, y); | |
int t = *x; | |
*x = *y; | |
*y = t - a / b * (*y); | |
return r; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment