You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using negative integers for base and power getting the below error:
RangeError: Maximum call stack size exceeded
at fastPowering (C:\Users\techn\Music\react-interview\testapp\app.js:17:23)
at fastPowering (C:\Users\techn\Music\react-interview\testapp\app.js:34:22)
at fastPowering (C:\Users\techn\Music\react-interview\testapp\app.js:34:22)
at fastPowering (C:\Users\techn\Music\react-interview\testapp\app.js:34:22)
at fastPowering (C:\Users\techn\Music\react-interview\testapp\app.js:34:22)
at fastPowering (C:\Users\techn\Music\react-interview\testapp\app.js:34:22)
at fastPowering (C:\Users\techn\Music\react-interview\testapp\app.js:34:22)
at fastPowering (C:\Users\techn\Music\react-interview\testapp\app.js:34:22)
at fastPowering (C:\Users\techn\Music\react-interview\testapp\app.js:34:22)
at fastPowering (C:\Users\techn\Music\react-interview\testapp\app.js:34:22)
Issue of the description:
When using negative integers for base and power getting the below error:
RangeError: Maximum call stack size exceeded
at fastPowering (C:\Users\techn\Music\react-interview\testapp\app.js:17:23)
at fastPowering (C:\Users\techn\Music\react-interview\testapp\app.js:34:22)
at fastPowering (C:\Users\techn\Music\react-interview\testapp\app.js:34:22)
at fastPowering (C:\Users\techn\Music\react-interview\testapp\app.js:34:22)
at fastPowering (C:\Users\techn\Music\react-interview\testapp\app.js:34:22)
at fastPowering (C:\Users\techn\Music\react-interview\testapp\app.js:34:22)
at fastPowering (C:\Users\techn\Music\react-interview\testapp\app.js:34:22)
at fastPowering (C:\Users\techn\Music\react-interview\testapp\app.js:34:22)
at fastPowering (C:\Users\techn\Music\react-interview\testapp\app.js:34:22)
at fastPowering (C:\Users\techn\Music\react-interview\testapp\app.js:34:22)
fastPowering(5,-5);
fastPowering(-5,5);
https://github.com/trekhleb/javascript-algorithms/blob/master/src/algorithms/math/fast-powering/fastPowering.js
It can be resolved by adding the below if statement to the code.
if(power<0){ power=power*-1; base=1/base; // console.log(base); fastPowering(base,power); }
Can I open a pull request to work on this?
The text was updated successfully, but these errors were encountered: