fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. long int GCD(int num1, int num2)
  5. {
  6. if(num1 == num2) return num1;
  7. while(num1 && num2)
  8. {
  9. if(num1 > num2) num1 %= num2;
  10. else num2 %= num1;
  11. }
  12. return num1+num2;
  13. }
  14.  
  15. int main() {
  16. long int num1, num2, gcd;
  17. cin >> num1 >> num2;
  18. gcd = GCD(num1, num2);
  19. cout << num1*num2/gcd;
  20. return 0;
  21. }
Success #stdin #stdout 0s 4932KB
stdin
24 42
stdout
168