Advertisement
heian

Untitled

Oct 23rd, 2019
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. /**
  6. Se citesc doua numere naturale a,b.
  7. a)Sa se afiseze cel mai mare divizor comun al lor.
  8. b)Sa se afiseze cel mai mic multiplu comun al lor.
  9. */
  10.  
  11. int main()
  12. {
  13. int a,b,r, A, B;
  14. cin>>a>>b;
  15. A = a;
  16. B = b;
  17. r = a%b;
  18. while(r)
  19. {
  20. a = b;
  21. b = r;
  22. r = a%b;
  23. }
  24. ///acum, cmmdc se va afla in b
  25. cout<<b<<"\n";
  26. cout<<(A*B)/b<<"\n";
  27. return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement