-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Add algorithm IsPrimeNumber #562
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
khanhkhanhlele
commented
Nov 10, 2025
- I have performed a self-review of my code
- My code follows the style guidelines of this project
- I have added tests that prove my fix is effective or that my feature works
- New and existing unit tests pass locally with my changes
- Comments in areas I changed are up to date
- I have added comments to hard-to-understand areas of my code
- I have made corresponding changes to the README.md
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.
Pull Request Overview
This PR adds a new deterministic prime number checker to the Algorithms.Numeric namespace, implementing an optimized trial division algorithm using the 6k±1 optimization technique. This complements the existing Miller-Rabin probabilistic primality test by providing a simpler, deterministic alternative suitable for smaller integers.
- Implements
PrimeChecker.IsPrime()method using trial division with 6k±1 optimization - Adds comprehensive unit tests covering edge cases, small primes, and composite numbers
- Provides clear documentation explaining the algorithm and its optimization approach
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| Algorithms/Numeric/PrimeChecker.cs | New static class implementing optimized trial division algorithm for primality testing |
| Algorithms.Tests/Numeric/PrimeNumberTest.cs | Comprehensive test suite with 14 test cases covering negative numbers, zero, primes, and composites |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #562 +/- ##
=======================================
Coverage 96.85% 96.86%
=======================================
Files 287 288 +1
Lines 11861 11882 +21
Branches 1706 1712 +6
=======================================
+ Hits 11488 11509 +21
Misses 237 237
Partials 136 136 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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.
Pull Request Overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
siriak
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.
Looks good, thanks!