GCD and LCM
Easy 20 XPMath
Commonly asked at TCS, Accenture
Read two positive integers a and b on one line. Print their GCD (greatest common divisor) and LCM (least common multiple) separated by a space. Try Euclid's algorithm instead of math.gcd.
- Input
- One line: a b.
- Output
- GCD LCM
Sample 1
Input
12 18
Output
6 36
Read input with input() (no prompt message) and print only the answer. Run tries the Input box; Submit checks all test cases.
Output Loading Python (first time takes a few seconds)
Press Run to see the result here.The solution unlocks after 3 submissions.