Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int NWD (int a, int b)
- {
- if (a>b)
- {
- int c=a;
- a=b;
- b=a;
- }
- for (int i=a; i>0; i--)
- {
- if (a%i==0 && b%i==0)
- {
- return i;
- }
- }
- }
- int main()
- {
- cout<<NWD(50,25)<<endl;
- cout<<NWD(1527,7252)<<endl;
- cout<<NWD(162,78)<<endl;
- cout<<NWD(124,908)<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement