Day 91: GCD Using Recursion of 100DaysCodingChallenge

Hello all, 

#day91 

Day91 

Today's my task was to Write a Program to Find GCD of two numbers entered by user using Recursion.

I have started the 100 days of coding challenge to improve my programming skills..

Code : 

let a = prompt("Enter a : ");
let b = prompt("Enter b : ");
var gcd = function(a, b) {
  if (!b) {
    return a;
  }
  return gcd(b, a % b);
};
//console.log(gcd(2154, 458));
console.log(gcd(a, b));

Output :     

 




Happy Coding:)

Thank you...      

Comments

Popular posts from this blog

Day 55: Pattern using loops of 100DaysCodingChallenge

Day 7: Square or Power Integer Numbers of 100DaysCodingChallenge

Day 45: Pattern using loops of 100DaysCodingChallenge