Write a recursive program to compute the exponent of a number:
8^3 = 8 * 8 * 8 = 512
This one is kind of easy, if you've finished the others.
You're just multiplying, 8 by all the other eights and returning the number.
Don't make this harder than it needs to be.
Once you've multiplied one eight, you've got one less exponent, etc...
var exponent = function(number, exp){
ReplyDeleteif(exp === 0){
return 1;
}
return number * exponent(number, exp -1);
}