-
-
Notifications
You must be signed in to change notification settings - Fork 46.6k
improved prime_check
in math modules
#6044
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
maths/prime_check.py
Outdated
@@ -32,12 +32,15 @@ def prime_check(number: int) -> bool: | |||
if 1 < number < 4: | |||
# 2 and 3 are primes | |||
return True | |||
elif number < 2 or not number % 2: | |||
# Negatives, 0, 1 and all even numbers are not primes | |||
elif number < 2 or not number % 2 or number % 3 == 0: |
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.
elif number < 2 or not number % 2 or number % 3 == 0: | |
elif number < 2 or number % 2 == 0 or number % 3 == 0: |
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.
What about numbers like 25, 35, 65 etc ?
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.
Those numbers are divisible by 5 6k-1 we are starting our loop with 5
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 review my changes and give your valuable feed back |
Related #6228 |
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.
Thank you for your pull request!🤩
I'd approve this because this uses one of the properties - I can't tell if it's intuitive or not though
Describe your change:
Checklist:
Fixes: #{$ISSUE_NO}
.