Published on January 26, 2024By DeveloperBreeze

// Function to calculate the GCD of two numbers using the Euclidean Algorithm
function calculateGCD(a, b) {
    while (b !== 0) {
        const temp = b;
        b = a % b;
        a = temp;
    }
    return a;
}

// Calculate and log the GCD of two numbers (e.g., 48 and 18)
const gcd = calculateGCD(48, 18);
console.log('GCD of Two Numbers:', gcd);

Comments

Please log in to leave a comment.

Continue Reading:

Generate Random Password

Published on January 26, 2024

javascriptpythonphp

Detecting Browser and Version

Published on January 26, 2024

javascript

Detect Dark Mode Preference

Published on January 26, 2024

javascript

Calculate Distance Between Two Points

Published on January 26, 2024

javascript

Convert Array of Objects to CSV

Published on January 26, 2024

javascript

Validate Password Strength

Published on January 26, 2024

javascript

Parse JSON String to Object

Published on January 26, 2024

javascript