Skip to content

Implemented chinese remainder theorem with test file #5873

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 14 commits into from
Oct 25, 2024

Conversation

SuprHUlk
Copy link
Contributor

Description of Change

This pull request implements the Chinese Remainder Theorem (CRT) algorithm to solve issue #5772.

The implementation includes:

  • A function (solveCRT) that calculates the solution using the product of moduli and their modular inverses.
  • A helper method (modInverse) that computes the modular inverse using the Extended Euclidean Algorithm.
  • Detailed documentation adhering to Doxygen standards, with a reference to Wikipedia for further details.
  • Comprehensive unit tests that verify the implementation across different scenarios, including simple cases, larger numbers, and edge cases to ensure accuracy and reliability.

Checklist

  • I have read CONTRIBUTING.md.
  • This pull request is all my own work -- I have not plagiarized it.
  • All filenames are in PascalCase.
  • All functions and variable names follow Java naming conventions.
  • All new algorithms have a URL in their comments that points to Wikipedia or other similar explanations.
  • All new code is formatted with clang-format -i --style=file path/to/your/file.java.

@codecov-commenter
Copy link

codecov-commenter commented Oct 16, 2024

Codecov Report

Attention: Patch coverage is 86.66667% with 4 lines in your changes missing coverage. Please review.

Project coverage is 68.81%. Comparing base (e154a50) to head (6da50d1).

Files with missing lines Patch % Lines
...m/thealgorithms/maths/ChineseRemainderTheorem.java 86.66% 2 Missing and 2 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #5873      +/-   ##
============================================
+ Coverage     68.77%   68.81%   +0.04%     
- Complexity     4637     4644       +7     
============================================
  Files           621      622       +1     
  Lines         17116    17146      +30     
  Branches       3302     3308       +6     
============================================
+ Hits          11771    11799      +28     
- Misses         4893     4894       +1     
- Partials        452      453       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@siriak siriak left a comment

Choose a reason for hiding this comment

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

Looks good, thanks!

@siriak siriak enabled auto-merge (squash) October 25, 2024 17:44
@siriak siriak disabled auto-merge October 25, 2024 17:44
@siriak siriak enabled auto-merge (squash) October 25, 2024 17:44
@siriak siriak merged commit 3b2ba48 into TheAlgorithms:master Oct 25, 2024
6 checks passed
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