Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int extendedEuclid(int a, int b, int &x, int &y) {
- int xx = y = 0;
- int yy = x = 1;
- while (b) {
- int q = a / b;
- int t = b; b = a % b; a = t;
- t = xx; xx = x - q * xx; x = t;
- t = yy; yy = y - q * yy; y = t;
- }
- return a;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement