c++ program to find lcm of two numbers

#include <iostream>

// Function to find the Greatest Common Divisor (GCD) of two numbers
int findGCD(int a, int b) {
    while (b != 0) {
        int temp = b;
        b = a % b;
        a = temp;
    }
    return a;
}

// Function to find the Least Common Multiple (LCM) of two numbers
int findLCM(int num1, int num2) {
    // Calculate the product of the two numbers
    int product = num1 * num2;

    // Use the GCD formula to find the LCM
    int gcd = findGCD(num1, num2);
    int lcm = product / gcd;

    return lcm;
}

// Main function
int main() {
    // Input two numbers
    int num1, num2;
    std::cout << "Enter first number: ";
    std::cin >> num1;
    std::cout << "Enter second number: ";
    std::cin >> num2;

    // Find and display the LCM of the two numbers
    int lcm = findLCM(num1, num2);
    std::cout << "LCM of " << num1 << " and " << num2 << " is: " << lcm;

    return 0;
}