Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added the condition to handle negative integers for fastPowering algorithm. #591

Open
wants to merge 16 commits into
base: master
Choose a base branch
from

Conversation

nikikalwar
Copy link

Issue:

Error:RangeError: Maximum call stack size exceeded #590

I have edited the fastpowering algorithm to handle negative integers and the test file to check the negative integers condition.

nikikalwar and others added 9 commits December 15, 2020 07:12

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
@JackyYin
Copy link

How about checking for power equals 1,
this can avoid from calculate fastPowering(base, 1) = fastPowering(base, 0) * fastPowering(base, 0) * base everytimes.

if (power === 0) {
  // Anything that is raised to the power of zero is 1.
  return 1;
}

if (power === 1) {
  return base;
}

.
.
.

nikikalwar and others added 5 commits December 19, 2020 03:32

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
nikikalwar pushed a commit to nikikalwar/javascript-algorithms that referenced this pull request Jun 23, 2021

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants