Skip to content

Added Exponent Finding program #2236

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

Closed
wants to merge 2 commits into from
Closed

Added Exponent Finding program #2236

wants to merge 2 commits into from

Conversation

Utsav1999
Copy link
Contributor

@Utsav1999 Utsav1999 commented Jul 25, 2020

Describe your change:

This Python recursion program is for finding exponent.

  • Add an algorithm?
  • Fix a bug or typo in an existing algorithm?
  • Documentation change?

Checklist:

  • I have read CONTRIBUTING.md.
  • This pull request is all my own work -- I have not plagiarized.
  • I know that pull requests will not be merged if they fail the automated tests.
  • This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms.
  • All new Python files are placed inside an existing directory.
  • All filenames are in all lowercase characters with no spaces or dashes.
  • All functions and variable names follow Python naming conventions.
  • All function parameters and return values are annotated with Python type hints.
  • All functions have doctests that pass the automated testing.
  • All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation.
  • If this pull request resolves one or more open issues then the commit message contains Fixes: #{$ISSUE_NO}.

@TravisBuddy
Copy link

Hey @Utsav1999,
Something went wrong with the build.

TravisCI finished with status errored, which means the build failed because of something unrelated to the tests, such as a problem with a dependency or the build process itself.

View build log

TravisBuddy Request Identifier: 594dbd40-ceb9-11ea-84f0-41e93e5606ac

@Utsav1999
Copy link
Contributor Author

The command "flake8 --ignore=E203,W503 --max-complexity=25 --max-line-length=88 --statistics --count ." failed and exited with 1 during .

How to resolve this?

@lance-pyles
Copy link
Contributor

The issues are listed. Go to details then The build link and scroll down. Looks like formatting issues mostly.

@cclauss
Copy link
Member

cclauss commented Jul 25, 2020

@vasugamdha
Copy link
Contributor

I can help you to pass these checks but i don't know how to help and edit the code in this PR? @Utsav1999

@cclauss
Copy link
Member

cclauss commented Jul 26, 2020

Autofix with python3 -m pip install black ; black maths/exponent_recursion.py

o/p -->
2 to the power of 0: 1
'''
def powerCalculation(n: int, p: int)->int:
Copy link
Member

@cclauss cclauss Jul 26, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def powerCalculation(n: int, p: int)->int:
def power(base: int, exponent: int)->int:
"""
>>> all(power(base, exponent) == pow(base, exponent)
... for base in range(-10, 10) for exponent in range(10))
True
"""
return base * power(base, exponent - 1) if exponent > 0 else 1

Copy link
Member

@cclauss cclauss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does not properly handle negative exponents.

Co-authored-by: Christian Clauss <cclauss@me.com>
@TravisBuddy
Copy link

Hey @Utsav1999,
Something went wrong with the build.

TravisCI finished with status errored, which means the build failed because of something unrelated to the tests, such as a problem with a dependency or the build process itself.

View build log

TravisBuddy Request Identifier: e07ea170-cf50-11ea-9502-ed86ad10d0d8

@Utsav1999 Utsav1999 closed this Jul 26, 2020
@cclauss cclauss mentioned this pull request Jul 26, 2020
14 tasks
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.

5 participants