javascript
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.