Write a program to find the GCD and LCM of two given numbers.
Write a program to find the GCD and LCM of two given numbers.
Student
Skilled in SEO, content writing, and digital marketing. Completed several years of working in many organizations including multinational companies. I love to learn new things in life that keep me motivated.
In this program, we have two methods: findGCD and findLCM. The findGCD method uses the Euclidean algorithm to find the GCD of two numbers, while the findLCM method calculates the LCM using the formula (a * b) / gcd. The main method initializes two numbers, num1 and num2, and then calls the findGCD and findLCM methods to calculate their GCD and LCM, respectively. Finally, the results are printed to the screen.