Answers for "get recursion exponent power in javascript"

0

get recursion exponent power in javascript

//get recursion exponent power in javascript
//calcular potencia en javascript
const potenciacion=(base,exponente)=>{
if(exponente==1){
return base;
}
if(exponente==0){
return 1;
}
if(exponente<0){
 exponente*=(-1);
 return 1/(potenciacion(base,exponente-1) * base);
}
return potenciacion(base,exponente-1) * base;
}
console.log(potenciacion(2,2));
Posted by: Guest on February-22-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language