Write a program to find the GCD and LCM of two given numbers.
Write a java program to find the GCD and LCM of two given numbers.
470
19-Apr-2023
Aryan Kumar
24-Apr-2023In 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.