diff --git a/src/algorithms/math/fast-powering/fastPowering.js b/src/algorithms/math/fast-powering/fastPowering.js index 4f4a6b35..2c957340 100644 --- a/src/algorithms/math/fast-powering/fastPowering.js +++ b/src/algorithms/math/fast-powering/fastPowering.js @@ -13,6 +13,13 @@ export default function fastPowering(base, power) { // Anything that is raised to the power of zero is 1. return 1; } + + if (power < 0 ) { + const powerNext = power * -1; + const baseNext = 1 / base; + // console.log("sssss") + return fastPowering(baseNext, powerNext); + } if (power % 2 === 0) { // If the power is even...