Day 33: LCM of two numbers of 100DaysCodingChallenge
Hello all,
I have started the 100 days of coding challenge to improve my programming skills..
Today is the Day33 of 100DaysCodingChallenge for
LCM of two numbers input Numbers taken by the user.
Code :
let a = prompt("Enter a : "); let b = prompt("Enter b : "); let gcd = 1; let lcm = 1; for (let i = 0; i <= a && i <= b; i++) { if (a % i == 0 && b % i == 0) { gcd = i; } } lcm = (a * b) / gcd; console.log("The LCM of two numbers", a, "and", b, "is :", lcm);
Output :
Happy Coding:)
Comments
Post a Comment