mirror of
https://github.com/Hizenberg469/Algorithms-snippets.git
synced 2026-04-19 22:52:23 +03:00
12 lines
200 B
C++
12 lines
200 B
C++
//Extended gcd -> Recursive
|
|
|
|
tuple<int,int,int> extended_gcd( int a, int b){
|
|
|
|
if( b == 0 ){
|
|
return {1,0,a};
|
|
}
|
|
|
|
int x,y,g;
|
|
tie(x,y,g) = extended_gcd( b , a%b );
|
|
return {y , x - (a/b)*y , g};
|
|
} |