Advertisement
Guest User

Untitled

a guest
Nov 21st, 2014
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     char x='y';
  2.     int m, n;
  3.     while(x=='y'){
  4.         cout<<"Enter numbers (m,n):";
  5.         cin>>m;
  6.         cin.ignore();
  7.         cin>>n;
  8.         cout<<"GCD of "<<m<<" and "<<n<<" is "<<GCD(m,n)<<endl;
  9.         cout<<"Run again? y/n ";
  10.         cin>>x;
  11.     }
  12.  
  13. int GCD(int m, int n) {
  14.     if (n==0){
  15.         return m;
  16.     }else {
  17.         return GCD(n, m%n);
  18.     }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement