Facebook
From Subtle Peafowl, 3 Years ago, written in C++.
Embed
Download Paste or View Raw
Hits: 138
  1. #include <iostream>
  2.  
  3. using namespace std;
  4. int nwd (int a, int b)
  5. {
  6.     int r;
  7.     while(b>0)
  8.     {
  9.         r=a%b;
  10.         a=b;
  11.         b=r;
  12.     }
  13.     return a;
  14. }
  15. int main()
  16. {
  17.  
  18.     int a,b;
  19.     cout<< "Podaj a:"<<endl;
  20.     cin>>a;
  21.     cout<< "Podaj b:"<<endl;
  22.     cin>>b;
  23.     cout<< "NWD= "<< nwd(a,b);
  24.     return 0;
  25. }
  26.