Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int gcd(int a, int b){
- if(a==0) return b;
- else if (a == b-a) return a;
- else if (a < b-a) return gcd(a, b-a);
- else return gcd(b-a,a);
- }
- int main(){
- int a, b;
- cin >> a >> b;
- cout << gcd(a,b);
- return 0;
- }
Add Comment
Please, Sign In to add comment