Skip to content

Added solution for Project Euler problem 123 #3072

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

Merged
merged 1 commit into from
Nov 6, 2020

Conversation

ksr1122
Copy link
Contributor

@ksr1122 ksr1122 commented Oct 8, 2020

Name: Prime square remainders

Let pn be the nth prime: 2, 3, 5, 7, 11, ..., and
let r be the remainder when (pn−1)^n + (pn+1)^n is divided by pn^2.

For example, when n = 3, p3 = 5, and 43 + 63 = 280 ≡ 5 mod 25.
The least value of n for which the remainder first exceeds 10^9 is 7037.

Find the least value of n for which the remainder first exceeds 10^10.

Reference: https://projecteuler.net/problem=123

reference: #2695

Describe your change:

  • 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}.

@ksr1122 ksr1122 force-pushed the problem_123 branch 2 times, most recently from db0746b to a254084 Compare October 9, 2020 08:40
@ksr1122 ksr1122 changed the title problem_123: project euler solution 120 problem_123: project euler solution 123 Oct 9, 2020
@ksr1122 ksr1122 changed the title problem_123: project euler solution 123 Hacktoberfest: project euler solution 123 Oct 9, 2020
@ksr1122 ksr1122 force-pushed the problem_123 branch 2 times, most recently from b676eec to 2c3d856 Compare October 10, 2020 09:36
@ksr1122 ksr1122 changed the title Hacktoberfest: project euler solution 123 Added solution for Project Euler problem 123 Oct 10, 2020
@ksr1122 ksr1122 requested a review from dhruvmanila as a code owner October 10, 2020 17:19
Copy link
Member

@dhruvmanila dhruvmanila left a comment

Choose a reason for hiding this comment

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

Announcement:

@ksr1122

This message is sent to all pull requests which are OPEN, NOT MERGED, not containing 'wontfix' label and contains 'Project Euler' or 'Project' or 'Euler' (case doesn't matter) in their title. If this message doesn't apply to your pull request, please ignore this.

Message:

This is to notify all the users submitting a pull request for the Project Euler solution that the README.md file has been updated with all the style requirements necessary for the directory and solution files. Please read through it and make all the necessary changes required to your submission.

@dhruvmanila dhruvmanila added the awaiting changes A maintainer has requested changes to this PR label Oct 24, 2020
@ksr1122 ksr1122 requested a review from Kush1101 as a code owner October 24, 2020 09:42
@dhruvmanila dhruvmanila added the tests are failing Do not merge until tests pass label Oct 29, 2020
@ksr1122
Copy link
Contributor Author

ksr1122 commented Oct 29, 2020

Pipeline is failing for some unknown reason.

fatal: unable to access 'https://gitlab.com/pycqa/flake8/': The requested URL returned error: 502

@ksr1122 ksr1122 force-pushed the problem_123 branch 2 times, most recently from a14c253 to dd18fc8 Compare October 29, 2020 08:59
@dhruvmanila dhruvmanila added require type hints https://docs.python.org/3/library/typing.html and removed tests are failing Do not merge until tests pass labels Nov 4, 2020
Name: Prime square remainders

Let pn be the nth prime: 2, 3, 5, 7, 11, ..., and
let r be the remainder when (pn−1)^n + (pn+1)^n is divided by pn^2.

For example, when n = 3, p3 = 5, and 43 + 63 = 280 ≡ 5 mod 25.
The least value of n for which the remainder first exceeds 10^9 is 7037.

Find the least value of n for which the remainder first exceeds 10^10.

Reference: https://projecteuler.net/problem=123

reference: TheAlgorithms#2695
@dhruvmanila dhruvmanila removed require type hints https://docs.python.org/3/library/typing.html awaiting changes A maintainer has requested changes to this PR labels Nov 6, 2020
@dhruvmanila dhruvmanila merged commit c8db6a2 into TheAlgorithms:master Nov 6, 2020
@dhruvmanila
Copy link
Member

Thank you for your contribution!

stokhos pushed a commit to stokhos/Python that referenced this pull request Jan 3, 2021
Name: Prime square remainders

Let pn be the nth prime: 2, 3, 5, 7, 11, ..., and
let r be the remainder when (pn−1)^n + (pn+1)^n is divided by pn^2.

For example, when n = 3, p3 = 5, and 43 + 63 = 280 ≡ 5 mod 25.
The least value of n for which the remainder first exceeds 10^9 is 7037.

Find the least value of n for which the remainder first exceeds 10^10.

Reference: https://projecteuler.net/problem=123

reference: TheAlgorithms#2695

Co-authored-by: Ravi Kandasamy Sundaram <[email protected]>
peRFectBeliever pushed a commit to peRFectBeliever/Python that referenced this pull request Apr 1, 2021
Name: Prime square remainders

Let pn be the nth prime: 2, 3, 5, 7, 11, ..., and
let r be the remainder when (pn−1)^n + (pn+1)^n is divided by pn^2.

For example, when n = 3, p3 = 5, and 43 + 63 = 280 ≡ 5 mod 25.
The least value of n for which the remainder first exceeds 10^9 is 7037.

Find the least value of n for which the remainder first exceeds 10^10.

Reference: https://projecteuler.net/problem=123

reference: TheAlgorithms#2695

Co-authored-by: Ravi Kandasamy Sundaram <[email protected]>
Panquesito7 pushed a commit to Panquesito7/Python that referenced this pull request May 13, 2021
Name: Prime square remainders

Let pn be the nth prime: 2, 3, 5, 7, 11, ..., and
let r be the remainder when (pn−1)^n + (pn+1)^n is divided by pn^2.

For example, when n = 3, p3 = 5, and 43 + 63 = 280 ≡ 5 mod 25.
The least value of n for which the remainder first exceeds 10^9 is 7037.

Find the least value of n for which the remainder first exceeds 10^10.

Reference: https://projecteuler.net/problem=123

reference: TheAlgorithms#2695

Co-authored-by: Ravi Kandasamy Sundaram <[email protected]>
shermanhui pushed a commit to shermanhui/Python that referenced this pull request Oct 22, 2021
Name: Prime square remainders

Let pn be the nth prime: 2, 3, 5, 7, 11, ..., and
let r be the remainder when (pn−1)^n + (pn+1)^n is divided by pn^2.

For example, when n = 3, p3 = 5, and 43 + 63 = 280 ≡ 5 mod 25.
The least value of n for which the remainder first exceeds 10^9 is 7037.

Find the least value of n for which the remainder first exceeds 10^10.

Reference: https://projecteuler.net/problem=123

reference: TheAlgorithms#2695

Co-authored-by: Ravi Kandasamy Sundaram <[email protected]>
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.

3 participants