Example 36: Find LCM and GCD

Learn how to calculate LCM and GCD using functions.

Problem

Write a program that takes two integers as input and obtains LCM and GCD of them through the functions lcm() and gcd().

Examples

Input Output (LCM) Output (GCD)
4 , 5 20 1
3 , 12 12 3

Try it yourself - LCM

Try to solve the LCM problem on your own in the code widget below. If you get stuck, you can always refer to the solution provided.

Get hands-on with 1400+ tech skills courses.