programming-examples/js/Recursion/Write a JavaScript program to compute the exponent of a number..js
2019-11-15 12:59:38 +01:00

13 lines
194 B
JavaScript

var exponent = function(a, n)
{
if (n === 0)
{
return 1;
}
else
{
return a * exponent(a, n-1);
}
};
console.log(exponent(4, 2));