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