programming-examples/js/Recursion/Write a JavaScript program to compute the exponent of a number..js

13 lines
194 B
JavaScript
Raw Normal View History

2019-11-15 12:59:38 +01:00
var exponent = function(a, n)
{
if (n === 0)
{
return 1;
}
else
{
return a * exponent(a, n-1);
}
};
console.log(exponent(4, 2));