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