Day 92: LCM Using Recursion of 100DaysCodingChallenge
Hello all,
#day92
Day92
Today's my task was to Write a Program to Find LCM of two numbers entered by user using Recursion.
I have started the 100 days of coding challenge to improve my programming skills..
Code :
// Javascript program to find LCM of two numbers // Recursive function to return gcd of a and b function gcd(a, b) { if (b == 0) return a; return gcd(b, a % b); } // Function to return LCM of two numbers function lcm(a, b) { return (a / gcd(a, b)) * b; } // Driver program to test above function // let a = 15, b = 20; let a = prompt("Enter a Number a : "); let b = prompt("Enter a Number b : "); console.log("LCM of " + a + " and " + b + " is " + lcm(a, b)); // This code is
Output :
Happy Coding:)
Thank you...
Comments
Post a Comment