fork download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main(void)
  6. {
  7. int n1, n2;
  8. int low = 1, high;
  9. int limit;
  10. cin >> n1 >> n2;
  11. limit = n1 > n2 ? n1 : n2;
  12.  
  13. for (int i = 2; i <= limit; i++)
  14. {
  15. if (n1 % i == 0 && n2 % i == 0)
  16. low = i;
  17. }
  18. high = n1 * n2 / low;
  19. cout << low << endl << high;
  20. return 0;
  21. }
Success #stdin #stdout 0s 4724KB
stdin
24 18
stdout
6
72