Advertisement
add1ctus

НЗД

Sep 30th, 2015
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.24 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int nzd(int a, int b)
  6. {
  7.     for(int i=a;i>=1;i--)
  8.         if(a%i==0 && b%i==0)
  9.             return i;
  10. }
  11.  
  12. int main()
  13. {
  14.     int a,b;
  15.     cin>>a>>b;
  16.     cout<<nzd(a,b);
  17.     return 0;
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement