Day 87: Exponential Using Recursion of 100DaysCodingChallenge

Hello all, 

#day87 

Day87 

Today's task was to write a program that gives the exponential of a given number entered by the user using Recursion.

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

Code : 

let n = prompt("Enter a Number : ");
let p = prompt("Enter a Power : ");
function exponential(num, power) {
  if (power == 1) {
    return num;
  }
  else {
    return num * exponential(num, power - 1);
  }
}
//exponential(3,4);
console.log(exponential(n, p));

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