Java icon indicating copy to clipboard operation
Java copied to clipboard

Implemented chinese remainder theorem with test file

Open SuprHUlk opened this issue 1 year ago • 1 comments

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

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

SuprHUlk avatar Oct 16 '24 11:10 SuprHUlk

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 :warning:
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     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov-commenter avatar Oct 16 '24 12:10 codecov-commenter