-
-
Notifications
You must be signed in to change notification settings - Fork 49.8k
Added solution for Project Euler problem 234 #3263
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
Conversation
dhruvmanila
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Announcement:
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.
project_euler/problem_234/sol2.py
Outdated
| return itertools.compress(itertools.count(), primes) | ||
|
|
||
|
|
||
| def pairwise(iterable: Iterator[int]) -> Iterator[tuple]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| def pairwise(iterable: Iterator[int]) -> Iterator[tuple]: | |
| def pairwise(iterable: Iterator[int]) -> Iterator[tuple[int]]: |
Is that correct?
Also, do you want an Iterator or an Iterable as your input?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Absolutey right, thanks!
|
Please leave a newline between the docstring and |
|
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
|
Please reopen this pull request once you commit the changes requested or make improvements on the code. If this is not the case and you need some help, feel free to seek help from our Gitter or ping one of the reviewers. Thank you for your contributions! |
Name: Semidivisible numbers
For an integer n ≥ 4, we define the lower prime square root of n, denoted by lps(n), as the largest prime ≤ √n and the upper prime square root of n, ups(n), as the smallest prime ≥ √n.
So, for example, lps(4) = 2 = ups(4), lps(1000) = 31, ups(1000) = 37.
Let us call an integer n ≥ 4 semidivisible, if one of lps(n) and ups(n) divides n, but not both.
The sum of the semidivisible numbers not exceeding 15 is 30, the numbers are 8, 10 and 12.
15 is not semidivisible because it is a multiple of both lps(15) = 3 and ups(15) = 5.
As a further example, the sum of the 92 semidivisible numbers up to 1000 is 34825.
What is the sum of all semidivisible numbers not exceeding 999966663333 ?
Note:
My solution is very similar at its core to sol1.py. Mine removes a few loops that slow down the algorithm and adds a nice prime iterator.
Reference: https://projecteuler.net/problem=234
Reference: #2695
Checklist:
Fixes: #{$ISSUE_NO}.