Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- /**
- Algoritmul lui Euclid, cu care putem calcula
- CMMDC si CMMMC dintre doua numere
- */
- /**
- CMMMDC(a,b) = CMMDC(a,a-b)
- CMMMC(a,b) = a*b/CMMDC(a,b)
- */
- int main()
- {
- int a,b,r,A,B;
- cin>>a>>b;
- A = a;
- B = b;
- r = a%b;
- while(r>0)
- {
- a = b;
- b = r;
- r = a%b;
- }
- cout<<"CMMDC="<<b<<"\n";
- cout<<"CMMMC="<<A*B/b<<"\n";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement